still working

This commit is contained in:
jed
2012-11-28 16:29:15 -08:00
parent 725761d60e
commit e90a1a404d
3 changed files with 18 additions and 6 deletions

View File

@@ -876,14 +876,15 @@ void NetworkOPs::setMode(OperatingMode om)
mMode = om; mMode = om;
} }
std::vector< std::pair<uint32, uint256> > std::vector< std::pair<uint32, uint256> >
NetworkOPs::getAffectedAccounts(const RippleAddress& account, uint32 minLedger, uint32 maxLedger) NetworkOPs::getAccountTxs(const RippleAddress& account, uint32 minLedger, uint32 maxLedger)
{ {
std::vector< std::pair<uint32, uint256> > affectedAccounts; std::vector< std::pair<uint32, uint256> > affectedAccounts;
std::string sql = std::string sql =
str(boost::format("SELECT LedgerSeq,TransID FROM AccountTransactions INDEXED BY AcctTxIndex " str(boost::format("SELECT LedgerSeq,Status,RawTxn,TxnMeta FROM Transactions where TransID in (SELECT TransID from AccountTransactions "
" WHERE Account = '%s' AND LedgerSeq <= '%d' AND LedgerSeq >= '%d' ORDER BY LedgerSeq LIMIT 1000;") " WHERE Account = '%s' AND LedgerSeq <= '%d' AND LedgerSeq >= '%d' LIMIT 1000) ORDER BY LedgerSeq;")
% account.humanAccountID() % maxLedger % minLedger); % account.humanAccountID() % maxLedger % minLedger);
{ {
@@ -892,6 +893,7 @@ std::vector< std::pair<uint32, uint256> >
SQL_FOREACH(db, sql) SQL_FOREACH(db, sql)
{ {
affectedAccounts.push_back(std::make_pair<uint32, uint256>(db->getInt("LedgerSeq"), uint256(db->getStrBinary("TransID")))); affectedAccounts.push_back(std::make_pair<uint32, uint256>(db->getInt("LedgerSeq"), uint256(db->getStrBinary("TransID"))));
} }
} }
@@ -1076,6 +1078,7 @@ Json::Value NetworkOPs::transJson(const SerializedTransaction& stTxn, TER terRes
void NetworkOPs::pubAcceptedTransaction(Ledger::ref lpCurrent, const SerializedTransaction& stTxn, TER terResult,TransactionMetaSet::pointer& meta) void NetworkOPs::pubAcceptedTransaction(Ledger::ref lpCurrent, const SerializedTransaction& stTxn, TER terResult,TransactionMetaSet::pointer& meta)
{ {
Json::Value jvObj = transJson(stTxn, terResult, true, lpCurrent, "transaction"); Json::Value jvObj = transJson(stTxn, terResult, true, lpCurrent, "transaction");
if(meta) jvObj["meta"]=meta->getJson(0);
{ {
boost::recursive_mutex::scoped_lock sl(mMonitorLock); boost::recursive_mutex::scoped_lock sl(mMonitorLock);

View File

@@ -231,7 +231,7 @@ public:
// client information retrieval functions // client information retrieval functions
std::vector< std::pair<uint32, uint256> > std::vector< std::pair<uint32, uint256> >
getAffectedAccounts(const RippleAddress& account, uint32 minLedger, uint32 maxLedger); getAccountTxs(const RippleAddress& account, uint32 minLedger, uint32 maxLedger);
std::vector<RippleAddress> getLedgerAffectedAccounts(uint32 ledgerSeq); std::vector<RippleAddress> getLedgerAffectedAccounts(uint32 ledgerSeq);
std::vector<SerializedTransaction> getLedgerTransactions(uint32 ledgerSeq); std::vector<SerializedTransaction> getLedgerTransactions(uint32 ledgerSeq);

View File

@@ -1292,14 +1292,20 @@ Json::Value RPCHandler::doAccountTransactions(const Json::Value& params)
try try
{ {
#endif #endif
std::vector< std::pair<uint32, uint256> > txns = mNetOps->getAffectedAccounts(account, minLedger, maxLedger); std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> > txns = mNetOps->getAccountTxs(account, minLedger, maxLedger);
Json::Value ret(Json::objectValue); Json::Value ret(Json::objectValue);
ret["account"] = account.humanAccountID(); ret["account"] = account.humanAccountID();
Json::Value ledgers(Json::arrayValue); Json::Value ledgers(Json::arrayValue);
// uint32 currentLedger = 0; // uint32 currentLedger = 0;
for (std::vector< std::pair<uint32, uint256> >::iterator it = txns.begin(), end = txns.end(); it != end; ++it) for (std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> >::iterator it = txns.begin(), end = txns.end(); it != end; ++it)
{ {
Json::objectValue obj;
obj["tx"]=it->first->getJson(1);
obj["meta"]=it->second->getJson(0);
ret["transactions"].append(obj);
Transaction::pointer txn = theApp->getMasterTransaction().fetch(it->second, true); Transaction::pointer txn = theApp->getMasterTransaction().fetch(it->second, true);
if (!txn) if (!txn)
{ {
@@ -1309,6 +1315,9 @@ Json::Value RPCHandler::doAccountTransactions(const Json::Value& params)
{ {
txn->setLedger(it->first); txn->setLedger(it->first);
ret["transactions"].append(txn->getJson(1)); ret["transactions"].append(txn->getJson(1));
TransactionMetaSet::pointer meta = boost::make_shared<TransactionMetaSet>(
stTxn.getTransactionID(), lpAccepted->getLedgerSeq(), it.getVL());
} }
} }