mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Use the new, simpler traverse logic.
This commit is contained in:
@@ -244,8 +244,8 @@ void LedgerAcquire::trigger(Peer::ref peer, bool timer)
|
||||
tmGL.set_ledgerhash(mHash.begin(), mHash.size());
|
||||
tmGL.set_ledgerseq(mLedger->getLedgerSeq());
|
||||
tmGL.set_itype(ripple::liTX_NODE);
|
||||
for (std::vector<SHAMapNode>::iterator it = nodeIDs.begin(); it != nodeIDs.end(); ++it)
|
||||
*(tmGL.add_nodeids()) = it->getRawString();
|
||||
BOOST_FOREACH(SHAMapNode& it, nodeIDs)
|
||||
*(tmGL.add_nodeids()) = it.getRawString();
|
||||
sendRequest(tmGL, peer);
|
||||
}
|
||||
}
|
||||
@@ -288,8 +288,8 @@ void LedgerAcquire::trigger(Peer::ref peer, bool timer)
|
||||
tmGL.set_ledgerhash(mHash.begin(), mHash.size());
|
||||
tmGL.set_ledgerseq(mLedger->getLedgerSeq());
|
||||
tmGL.set_itype(ripple::liAS_NODE);
|
||||
for (std::vector<SHAMapNode>::iterator it = nodeIDs.begin(); it != nodeIDs.end(); ++it)
|
||||
*(tmGL.add_nodeids()) = it->getRawString();
|
||||
BOOST_FOREACH(SHAMapNode& it, nodeIDs)
|
||||
*(tmGL.add_nodeids()) = it.getRawString();
|
||||
sendRequest(tmGL, peer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "LedgerEntrySet.h"
|
||||
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include "Log.h"
|
||||
|
||||
@@ -354,30 +355,30 @@ void LedgerEntrySet::calcRawMeta(Serializer& s, TER result)
|
||||
// Entries modified only as a result of building the transaction metadata
|
||||
boost::unordered_map<uint256, SLE::pointer> newMod;
|
||||
|
||||
for (std::map<uint256, LedgerEntrySetEntry>::const_iterator it = mEntries.begin(),
|
||||
end = mEntries.end(); it != end; ++it)
|
||||
typedef std::pair<const uint256, LedgerEntrySetEntry> u256_LES_pair;
|
||||
BOOST_FOREACH(u256_LES_pair& it, mEntries)
|
||||
{
|
||||
SField::ptr type = &sfGeneric;
|
||||
|
||||
switch (it->second.mAction)
|
||||
switch (it.second.mAction)
|
||||
{
|
||||
case taaMODIFY:
|
||||
#ifdef META_DEBUG
|
||||
cLog(lsTRACE) << "Modified Node " << it->first;
|
||||
cLog(lsTRACE) << "Modified Node " << it.first;
|
||||
#endif
|
||||
type = &sfModifiedNode;
|
||||
break;
|
||||
|
||||
case taaDELETE:
|
||||
#ifdef META_DEBUG
|
||||
cLog(lsTRACE) << "Deleted Node " << it->first;
|
||||
cLog(lsTRACE) << "Deleted Node " << it.first;
|
||||
#endif
|
||||
type = &sfDeletedNode;
|
||||
break;
|
||||
|
||||
case taaCREATE:
|
||||
#ifdef META_DEBUG
|
||||
cLog(lsTRACE) << "Created Node " << it->first;
|
||||
cLog(lsTRACE) << "Created Node " << it.first;
|
||||
#endif
|
||||
type = &sfCreatedNode;
|
||||
break;
|
||||
@@ -389,13 +390,13 @@ void LedgerEntrySet::calcRawMeta(Serializer& s, TER result)
|
||||
if (type == &sfGeneric)
|
||||
continue;
|
||||
|
||||
SLE::pointer origNode = mLedger->getSLE(it->first);
|
||||
SLE::pointer origNode = mLedger->getSLE(it.first);
|
||||
|
||||
if (origNode && (origNode->getType() == ltDIR_NODE)) // No metadata for dir nodes
|
||||
continue;
|
||||
|
||||
SLE::pointer curNode = it->second.mEntry;
|
||||
mSet.setAffectedNode(it->first, *type);
|
||||
SLE::pointer curNode = it.second.mEntry;
|
||||
mSet.setAffectedNode(it.first, *type);
|
||||
|
||||
if (type == &sfDeletedNode)
|
||||
{
|
||||
@@ -406,16 +407,16 @@ void LedgerEntrySet::calcRawMeta(Serializer& s, TER result)
|
||||
{ // node has an amount, covers ripple state nodes
|
||||
STAmount amount = origNode->getFieldAmount(sfAmount);
|
||||
if (amount.isNonZero())
|
||||
mSet.getAffectedNode(it->first).setFieldAmount(sfPreviousBalance, amount);
|
||||
mSet.getAffectedNode(it.first).setFieldAmount(sfPreviousBalance, amount);
|
||||
amount = curNode->getFieldAmount(sfAmount);
|
||||
if (amount.isNonZero())
|
||||
mSet.getAffectedNode(it->first).setFieldAmount(sfFinalBalance, amount);
|
||||
mSet.getAffectedNode(it.first).setFieldAmount(sfFinalBalance, amount);
|
||||
|
||||
if (origNode->getType() == ltRIPPLE_STATE)
|
||||
{
|
||||
mSet.getAffectedNode(it->first).setFieldAccount(sfLowID,
|
||||
mSet.getAffectedNode(it.first).setFieldAccount(sfLowID,
|
||||
NewcoinAddress::createAccountID(origNode->getFieldAmount(sfLowLimit).getIssuer()));
|
||||
mSet.getAffectedNode(it->first).setFieldAccount(sfHighID,
|
||||
mSet.getAffectedNode(it.first).setFieldAccount(sfHighID,
|
||||
NewcoinAddress::createAccountID(origNode->getFieldAmount(sfHighLimit).getIssuer()));
|
||||
}
|
||||
}
|
||||
@@ -424,10 +425,10 @@ void LedgerEntrySet::calcRawMeta(Serializer& s, TER result)
|
||||
{ // check for non-zero balances
|
||||
STAmount amount = origNode->getFieldAmount(sfTakerPays);
|
||||
if (amount.isNonZero())
|
||||
mSet.getAffectedNode(it->first).setFieldAmount(sfFinalTakerPays, amount);
|
||||
mSet.getAffectedNode(it.first).setFieldAmount(sfFinalTakerPays, amount);
|
||||
amount = origNode->getFieldAmount(sfTakerGets);
|
||||
if (amount.isNonZero())
|
||||
mSet.getAffectedNode(it->first).setFieldAmount(sfFinalTakerGets, amount);
|
||||
mSet.getAffectedNode(it.first).setFieldAmount(sfFinalTakerGets, amount);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -451,17 +452,17 @@ void LedgerEntrySet::calcRawMeta(Serializer& s, TER result)
|
||||
{ // node has an amount, covers account root nodes and ripple nodes
|
||||
STAmount amount = origNode->getFieldAmount(sfAmount);
|
||||
if (amount != curNode->getFieldAmount(sfAmount))
|
||||
mSet.getAffectedNode(it->first).setFieldAmount(sfPreviousBalance, amount);
|
||||
mSet.getAffectedNode(it.first).setFieldAmount(sfPreviousBalance, amount);
|
||||
}
|
||||
|
||||
if (origNode->getType() == ltOFFER)
|
||||
{
|
||||
STAmount amount = origNode->getFieldAmount(sfTakerPays);
|
||||
if (amount != curNode->getFieldAmount(sfTakerPays))
|
||||
mSet.getAffectedNode(it->first).setFieldAmount(sfPreviousTakerPays, amount);
|
||||
mSet.getAffectedNode(it.first).setFieldAmount(sfPreviousTakerPays, amount);
|
||||
amount = origNode->getFieldAmount(sfTakerGets);
|
||||
if (amount != curNode->getFieldAmount(sfTakerGets))
|
||||
mSet.getAffectedNode(it->first).setFieldAmount(sfPreviousTakerGets, amount);
|
||||
mSet.getAffectedNode(it.first).setFieldAmount(sfPreviousTakerGets, amount);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include "TransactionEngine.h"
|
||||
|
||||
@@ -18,12 +19,12 @@ SETUP_LOG();
|
||||
void TransactionEngine::txnWrite()
|
||||
{
|
||||
// Write back the account states
|
||||
for (std::map<uint256, LedgerEntrySetEntry>::iterator it = mNodes.begin(), end = mNodes.end();
|
||||
it != end; ++it)
|
||||
typedef std::pair<const uint256, LedgerEntrySetEntry> u256_LES_pair;
|
||||
BOOST_FOREACH(u256_LES_pair& it, mNodes)
|
||||
{
|
||||
const SLE::pointer& sleEntry = it->second.mEntry;
|
||||
const SLE::pointer& sleEntry = it.second.mEntry;
|
||||
|
||||
switch (it->second.mAction)
|
||||
switch (it.second.mAction)
|
||||
{
|
||||
case taaNONE:
|
||||
assert(false);
|
||||
@@ -54,7 +55,7 @@ void TransactionEngine::txnWrite()
|
||||
{
|
||||
cLog(lsINFO) << "applyTransaction: taaDELETE: " << sleEntry->getText();
|
||||
|
||||
if (!mLedger->peekAccountStateMap()->delItem(it->first))
|
||||
if (!mLedger->peekAccountStateMap()->delItem(it.first))
|
||||
assert(false);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -25,19 +25,19 @@ TransactionMetaSet::TransactionMetaSet(const uint256& txid, uint32 ledger, const
|
||||
|
||||
bool TransactionMetaSet::isNodeAffected(const uint256& node) const
|
||||
{
|
||||
for (STArray::const_iterator it = mNodes.begin(); it != mNodes.end(); ++it)
|
||||
if (it->getFieldH256(sfLedgerIndex) == node)
|
||||
BOOST_FOREACH(const STObject& it, mNodes)
|
||||
if (it.getFieldH256(sfLedgerIndex) == node)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void TransactionMetaSet::setAffectedNode(const uint256& node, SField::ref type)
|
||||
{ // make sure the node exists and force its type
|
||||
for (STArray::iterator it = mNodes.begin(); it != mNodes.end(); ++it)
|
||||
BOOST_FOREACH(STObject& it, mNodes)
|
||||
{
|
||||
if (it->getFieldH256(sfLedgerIndex) == node)
|
||||
if (it.getFieldH256(sfLedgerIndex) == node)
|
||||
{
|
||||
it->setFName(type);
|
||||
it.setFName(type);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -52,10 +52,10 @@ void TransactionMetaSet::setAffectedNode(const uint256& node, SField::ref type)
|
||||
STObject& TransactionMetaSet::getAffectedNode(const uint256& node, SField::ref type)
|
||||
{
|
||||
assert(&type);
|
||||
for (STArray::iterator it = mNodes.begin(); it != mNodes.end(); ++it)
|
||||
BOOST_FOREACH(STObject& it, mNodes)
|
||||
{
|
||||
if (it->getFieldH256(sfLedgerIndex) == node)
|
||||
return *it;
|
||||
if (it.getFieldH256(sfLedgerIndex) == node)
|
||||
return it;
|
||||
}
|
||||
|
||||
mNodes.push_back(STObject(sfModifiedNode));
|
||||
@@ -69,10 +69,10 @@ STObject& TransactionMetaSet::getAffectedNode(const uint256& node, SField::ref t
|
||||
|
||||
STObject& TransactionMetaSet::getAffectedNode(const uint256& node)
|
||||
{
|
||||
for (STArray::iterator it = mNodes.begin(); it != mNodes.end(); ++it)
|
||||
BOOST_FOREACH(STObject& it, mNodes)
|
||||
{
|
||||
if (it->getFieldH256(sfLedgerIndex) == node)
|
||||
return *it;
|
||||
if (it.getFieldH256(sfLedgerIndex) == node)
|
||||
return it;
|
||||
}
|
||||
assert(false);
|
||||
throw std::runtime_error("Affected node not found");
|
||||
@@ -80,9 +80,9 @@ STObject& TransactionMetaSet::getAffectedNode(const uint256& node)
|
||||
|
||||
const STObject& TransactionMetaSet::peekAffectedNode(const uint256& node) const
|
||||
{
|
||||
for (STArray::const_iterator it = mNodes.begin(); it != mNodes.end(); ++it)
|
||||
if (it->getFieldH256(sfLedgerIndex) == node)
|
||||
return *it;
|
||||
BOOST_FOREACH(const STObject& it, mNodes)
|
||||
if (it.getFieldH256(sfLedgerIndex) == node)
|
||||
return it;
|
||||
throw std::runtime_error("Affected node not found");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user