Bugfixes.

This commit is contained in:
JoelKatz
2012-06-09 18:28:34 -07:00
parent 8d8d2c6691
commit d888cc2da8
4 changed files with 13 additions and 17 deletions

View File

@@ -24,14 +24,12 @@ int TxnDBCount = sizeof(TxnDBInit) / sizeof(const char *);
const char *AcctTxnDBInit[] = {
"CREATE TABLE AccountTransactions ( \
TransID CHARACTER964) PRIMARY KEY \
TransID CHARACTER(64) PRIMARY KEY, \
Account CHARACTER(64), \
LedgerSeq BIGINT UNSIGNED, \
LedgerSeq BIGINT UNSIGNED \
);",
"CREATE INDEX AcctTxindex ON \
AccountTransactions(Account), \
AccountTransactions(LedgerSeq), \
AccountTransactions(TransID);"
AccountTransactions(Account, LedgerSeq, TransID);"
};
int AcctTxnDBCount = sizeof(AcctTxnDBInit) / sizeof(const char *);

View File

@@ -738,12 +738,12 @@ void LedgerConsensus::accept(SHAMap::pointer set)
SerializedTransaction txn(sit);
std::vector<NewcoinAddress> accts = txn.getAffectedAccounts();
std::string sql = "INSERT INTO AccountTransactions (TransID,Account,LedgerSeq) VALUES ";
std::string sql = "INSERT INTO AccountTransactions (TransID, Account, LedgerSeq) VALUES ";
bool first = true;
for (std::vector<NewcoinAddress>::iterator it = accts.begin(), end = accts.end(); it != end; ++it)
{
if (!first)
sql += ", (";
sql += ", ('";
else
{
sql += "('";
@@ -752,9 +752,9 @@ void LedgerConsensus::accept(SHAMap::pointer set)
sql += txn.getTransactionID().GetHex();
sql += "','";
sql += it->humanAccountID();
sql += "','";
sql += "',";
sql += boost::lexical_cast<std::string>(newLedgerSeq);
sql += "')";
sql += ")";
}
sql += ";";
Log(lsTRACE) << "ActTx: " << sql;

View File

@@ -539,8 +539,8 @@ std::vector< std::pair<uint32, uint256> >
std::string sql =
str(boost::format("SELECT LedgerSeq,TransID FROM AccountTransactions INDEXED BY AcctTxIndex "
" WHERE Account = %s AND LedgerSeq <= %d AND LedgerSeq >= %d ORDER BY LedgerSeq LIMIT 1000")
% account.humanAccountID() % minLedger % maxLedger);
" WHERE Account = '%s' AND LedgerSeq <= '%d' AND LedgerSeq >= '%d' ORDER BY LedgerSeq LIMIT 1000")
% account.humanAccountID() % maxLedger % minLedger);
Database *db = theApp->getAcctTxnDB()->getDB();
ScopedLock dbLock = theApp->getAcctTxnDB()->getDBLock();

View File

@@ -1502,19 +1502,17 @@ Json::Value RPCServer::doAccountTransactions(Json::Value& params)
try
{
#endif
std::vector< std::pair<uint32, uint256> > txns =
mNetOps->getAffectedAccounts(account, minLedger, maxLedger);
std::vector< std::pair<uint32, uint256> > txns = mNetOps->getAffectedAccounts(account, minLedger, maxLedger);
Json::Value ret(Json::objectValue);
ret["Account"] = account.humanAccountID();
Json::Value ledgers(Json::arrayValue);
uint32 currentLedger = 0;
Json::Value ledger, jtxns;
for (std::vector< std::pair<uint32, uint256> >::iterator it = txns.begin(),
end = txns.end(); it != end; ++it)
for (std::vector< std::pair<uint32, uint256> >::iterator it = txns.begin(), end = txns.end(); it != end; ++it)
{
if (it->first != currentLedger)
{ // new ledger
if (it->first != currentLedger) // different/new ledger
{
if (currentLedger != 0) // add old ledger
{
ledger["Transactions"] = jtxns;