From 809868c6fcd580f689887de9a0125e52074e34bb Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Thu, 17 Jan 2013 11:33:42 -0800 Subject: [PATCH] This is not optimal, but this should at least make the logic for when we publish transactions to which accounts sensible. --- src/cpp/ripple/NetworkOPs.cpp | 38 ++++------------------------------- src/cpp/ripple/NetworkOPs.h | 1 - 2 files changed, 4 insertions(+), 35 deletions(-) diff --git a/src/cpp/ripple/NetworkOPs.cpp b/src/cpp/ripple/NetworkOPs.cpp index d907ad963..cf4027480 100644 --- a/src/cpp/ripple/NetworkOPs.cpp +++ b/src/cpp/ripple/NetworkOPs.cpp @@ -1329,11 +1329,10 @@ void NetworkOPs::pubAccountTransaction(Ledger::ref lpCurrent, const SerializedTr if (!mSubAccount.empty() || (!mSubRTAccount.empty()) ) { - typedef std::map::value_type AccountPair; - - BOOST_FOREACH(const AccountPair& affectedAccount, getAffectedAccounts(stTxn)) + std::vector accounts = meta ? meta->getAffectedAccounts() : stTxn.getMentionedAccounts(); + BOOST_FOREACH(const RippleAddress& affectedAccount, accounts) { - subInfoMapIterator simiIt = mSubRTAccount.find(affectedAccount.first.getAccountID()); + subInfoMapIterator simiIt = mSubRTAccount.find(affectedAccount.getAccountID()); if (simiIt != mSubRTAccount.end()) { @@ -1345,7 +1344,7 @@ void NetworkOPs::pubAccountTransaction(Ledger::ref lpCurrent, const SerializedTr if (bAccepted) { - simiIt = mSubAccount.find(affectedAccount.first.getAccountID()); + simiIt = mSubAccount.find(affectedAccount.getAccountID()); if (simiIt != mSubAccount.end()) { @@ -1372,35 +1371,6 @@ void NetworkOPs::pubAccountTransaction(Ledger::ref lpCurrent, const SerializedTr } } -// JED: I know this is sort of ugly. I'm going to rework this to get the affected accounts in a different way when we want finer granularity than just "account" -std::map NetworkOPs::getAffectedAccounts(const SerializedTransaction& stTxn) -{ - std::map accounts; - - BOOST_FOREACH(const SerializedType& it, stTxn.peekData()) - { - const STAccount* sa = dynamic_cast(&it); - if (sa) - { - RippleAddress na = sa->getValueNCA(); - accounts[na]=true; - }else - { - if( it.getFName() == sfLimitAmount ) - { - const STAmount* amount = dynamic_cast(&it); - if(amount) - { - RippleAddress na; - na.setAccountID(amount->getIssuer()); - accounts[na]=true; - } - } - } - } - return accounts; -} - // // Monitoring // diff --git a/src/cpp/ripple/NetworkOPs.h b/src/cpp/ripple/NetworkOPs.h index 764dec483..401e9b67f 100644 --- a/src/cpp/ripple/NetworkOPs.h +++ b/src/cpp/ripple/NetworkOPs.h @@ -122,7 +122,6 @@ protected: void pubAcceptedTransaction(Ledger::ref lpCurrent, const SerializedTransaction& stTxn, TER terResult,TransactionMetaSet::pointer& meta); void pubAccountTransaction(Ledger::ref lpCurrent, const SerializedTransaction& stTxn, TER terResult,bool accepted,TransactionMetaSet::pointer& meta); - std::map getAffectedAccounts(const SerializedTransaction& stTxn); void pubServer();