Merge branch 'master' of github.com:jedmccaleb/NewCoin

This commit is contained in:
Arthur Britto
2013-01-18 01:49:08 -08:00
2 changed files with 28 additions and 23 deletions

View File

@@ -415,29 +415,34 @@ void Ledger::saveAcceptedLedger(bool fromConsensus, LoadEvent::pointer event)
if (!SQL_EXISTS(db, boost::str(AcctTransExists % item->getTag().GetHex()))) if (!SQL_EXISTS(db, boost::str(AcctTransExists % item->getTag().GetHex())))
{ {
// Transaction not in AccountTransactions // Transaction not in AccountTransactions
std::vector<RippleAddress> accts = meta.getAffectedAccounts(); const std::vector<RippleAddress> accts = meta.getAffectedAccounts();
if (!accts.empty())
std::string sql = "INSERT INTO AccountTransactions (TransID, Account, LedgerSeq) VALUES ";
bool first = true;
for (std::vector<RippleAddress>::iterator it = accts.begin(), end = accts.end(); it != end; ++it)
{ {
if (!first)
sql += ", ('"; std::string sql = "INSERT INTO AccountTransactions (TransID, Account, LedgerSeq) VALUES ";
else bool first = true;
for (std::vector<RippleAddress>::const_iterator it = accts.begin(), end = accts.end(); it != end; ++it)
{ {
sql += "('"; if (!first)
first = false; sql += ", ('";
else
{
sql += "('";
first = false;
}
sql += txn.getTransactionID().GetHex();
sql += "','";
sql += it->humanAccountID();
sql += "',";
sql += boost::lexical_cast<std::string>(getLedgerSeq());
sql += ")";
} }
sql += txn.getTransactionID().GetHex(); sql += ";";
sql += "','"; Log(lsTRACE) << "ActTx: " << sql;
sql += it->humanAccountID(); db->executeSQL(sql); // may already be in there
sql += "',";
sql += boost::lexical_cast<std::string>(getLedgerSeq());
sql += ")";
} }
sql += ";"; else
Log(lsTRACE) << "ActTx: " << sql; cLog(lsWARNING) << "Transaaction in ledger " << mLedgerSeq << " affects not accounts";
db->executeSQL(sql); // may already be in there
} }
if (SQL_EXISTS(db, boost::str(transExists % txn.getTransactionID().GetHex()))) if (SQL_EXISTS(db, boost::str(transExists % txn.getTransactionID().GetHex())))

View File

@@ -62,7 +62,7 @@ void SHAMap::getMissingNodes(std::vector<SHAMapNode>& nodeIDs, std::vector<uint2
if (filter->haveNode(childID, childHash, nodeData)) if (filter->haveNode(childID, childHash, nodeData))
{ {
SHAMapTreeNode::pointer ptr = SHAMapTreeNode::pointer ptr =
boost::make_shared<SHAMapTreeNode>(childID, nodeData, mSeq, snfPREFIX, childHash); boost::make_shared<SHAMapTreeNode>(childID, nodeData, mSeq - 1, snfPREFIX, childHash);
cLog(lsTRACE) << "Got sync node from cache: " << *d; cLog(lsTRACE) << "Got sync node from cache: " << *d;
mTNByID[*ptr] = ptr; mTNByID[*ptr] = ptr;
d = ptr.get(); d = ptr.get();
@@ -193,7 +193,7 @@ SMAddNode SHAMap::addRootNode(const std::vector<unsigned char>& rootNode, SHANod
return SMAddNode::okay(); return SMAddNode::okay();
} }
SHAMapTreeNode::pointer node = boost::make_shared<SHAMapTreeNode>(SHAMapNode(), rootNode, mSeq, format, uint256()); SHAMapTreeNode::pointer node = boost::make_shared<SHAMapTreeNode>(SHAMapNode(), rootNode, mSeq - 1, format, uint256());
if (!node) if (!node)
return SMAddNode::invalid(); return SMAddNode::invalid();
@@ -231,7 +231,7 @@ SMAddNode SHAMap::addRootNode(const uint256& hash, const std::vector<unsigned ch
return SMAddNode::okay(); return SMAddNode::okay();
} }
SHAMapTreeNode::pointer node = boost::make_shared<SHAMapTreeNode>(SHAMapNode(), rootNode, mSeq, format, uint256()); SHAMapTreeNode::pointer node = boost::make_shared<SHAMapTreeNode>(SHAMapNode(), rootNode, mSeq - 1, format, uint256());
if (!node || node->getNodeHash() != hash) if (!node || node->getNodeHash() != hash)
return SMAddNode::invalid(); return SMAddNode::invalid();
@@ -308,7 +308,7 @@ SMAddNode SHAMap::addKnownNode(const SHAMapNode& node, const std::vector<unsigne
return SMAddNode::invalid(); return SMAddNode::invalid();
} }
SHAMapTreeNode::pointer newNode = boost::make_shared<SHAMapTreeNode>(node, rawNode, mSeq, snfWIRE, uint256()); SHAMapTreeNode::pointer newNode = boost::make_shared<SHAMapTreeNode>(node, rawNode, mSeq - 1, snfWIRE, uint256());
if (hash != newNode->getNodeHash()) // these aren't the droids we're looking for if (hash != newNode->getNodeHash()) // these aren't the droids we're looking for
return SMAddNode::invalid(); return SMAddNode::invalid();