From 7d2e55346f51a104bf4ba317fd25838726023388 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Wed, 27 Jun 2012 20:39:00 -0700 Subject: [PATCH] Call NetworkOPs::pubTransaction. --- src/LedgerMaster.cpp | 10 ++++++++++ src/LedgerMaster.h | 3 +-- src/NetworkOPs.cpp | 3 ++- src/NetworkOPs.h | 2 +- src/TransactionEngine.cpp | 24 +++++++++++++++++------- src/TransactionEngine.h | 3 +++ 6 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/LedgerMaster.cpp b/src/LedgerMaster.cpp index ea1b4bdce7..7d86d5922d 100644 --- a/src/LedgerMaster.cpp +++ b/src/LedgerMaster.cpp @@ -91,4 +91,14 @@ Ledger::pointer LedgerMaster::endWobble() return ret; } +TransactionEngineResult LedgerMaster::doTransaction(const SerializedTransaction& txn, uint32 targetLedger, + TransactionEngineParams params) +{ + Ledger::pointer ledger = mEngine.getTransactionLedger(targetLedger); + TransactionEngineResult result = mEngine.applyTransaction(txn, params, ledger); + theApp->getOPs().pubTransaction(ledger, txn, result); + return result; +} + + // vim:ts=4 diff --git a/src/LedgerMaster.h b/src/LedgerMaster.h index 3ad41283e4..f31d0869ed 100644 --- a/src/LedgerMaster.h +++ b/src/LedgerMaster.h @@ -48,8 +48,7 @@ public: Ledger::pointer getClosedLedger() { return mFinalizedLedger; } TransactionEngineResult doTransaction(const SerializedTransaction& txn, uint32 targetLedger, - TransactionEngineParams params) - { return mEngine.applyTransaction(txn, params, targetLedger); } + TransactionEngineParams params); void pushLedger(Ledger::pointer newLedger); void pushLedger(Ledger::pointer newLCL, Ledger::pointer newOL); diff --git a/src/NetworkOPs.cpp b/src/NetworkOPs.cpp index 2f8afe372f..08bfa4e1ad 100644 --- a/src/NetworkOPs.cpp +++ b/src/NetworkOPs.cpp @@ -763,8 +763,9 @@ void NetworkOPs::pubLedger(const Ledger::pointer& lpAccepted) } } -void NetworkOPs::pubTransaction(const Ledger::pointer& lpCurrent, const SerializedTransaction& stTxn, TransactionEngineResult terResult, const std::vector& naAffectedAccountIds) +void NetworkOPs::pubTransaction(const Ledger::pointer& lpCurrent, const SerializedTransaction& stTxn, TransactionEngineResult terResult) { + // std::vector affectedAccounts = stTxn.getAffectedAccounts(); boost::interprocess::scoped_lock sl(mMonitorLock); if (!mSubTransaction.empty()) { diff --git a/src/NetworkOPs.h b/src/NetworkOPs.h index 8b3717b081..9ef9c38f29 100644 --- a/src/NetworkOPs.h +++ b/src/NetworkOPs.h @@ -165,7 +165,7 @@ public: void pubAccountInfo(const NewcoinAddress& naAccountID, const Json::Value& jvObj); void pubLedger(const Ledger::pointer& lpAccepted); - void pubTransaction(const Ledger::pointer& lpCurrent, const SerializedTransaction& stTxn, TransactionEngineResult terResult, const std::vector& naAffectedAccountIds); + void pubTransaction(const Ledger::pointer& lpLedger, const SerializedTransaction& stTxn, TransactionEngineResult terResult); // // Monitoring: subscriber side diff --git a/src/TransactionEngine.cpp b/src/TransactionEngine.cpp index 90495b3f4e..7545df35bb 100644 --- a/src/TransactionEngine.cpp +++ b/src/TransactionEngine.cpp @@ -289,19 +289,29 @@ TransactionEngineResult TransactionEngine::setAuthorized(const SerializedTransac return terSUCCESS; } -TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTransaction& txn, - TransactionEngineParams params, uint32 targetLedger) +Ledger::pointer TransactionEngine::getTransactionLedger(uint32 targetLedger) { - Log(lsTRACE) << "applyTransaction>"; - - mLedger = mDefaultLedger; - assert(mLedger); + Ledger::pointer ledger = mDefaultLedger; if (mAlternateLedger && (targetLedger != 0) && (targetLedger != mLedger->getLedgerSeq()) && (targetLedger == mAlternateLedger->getLedgerSeq())) { Log(lsINFO) << "Transaction goes into wobble ledger"; - mLedger = mAlternateLedger; + ledger = mAlternateLedger; } + return ledger; +} + +TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTransaction& txn, + TransactionEngineParams params, uint32 targetLedger) +{ + return applyTransaction(txn, params, getTransactionLedger(targetLedger)); +} + +TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTransaction& txn, + TransactionEngineParams params, Ledger::pointer ledger) +{ + Log(lsTRACE) << "applyTransaction>"; + mLedger = ledger; #ifdef DEBUG if (1) diff --git a/src/TransactionEngine.h b/src/TransactionEngine.h index 8a78ea6da0..960fff12b6 100644 --- a/src/TransactionEngine.h +++ b/src/TransactionEngine.h @@ -136,6 +136,9 @@ public: void setLedger(Ledger::pointer ledger) { mDefaultLedger = ledger; mAlternateLedger = Ledger::pointer(); } + Ledger::pointer getTransactionLedger(uint32 targetLedger); + TransactionEngineResult applyTransaction(const SerializedTransaction&, TransactionEngineParams, + Ledger::pointer ledger); TransactionEngineResult applyTransaction(const SerializedTransaction&, TransactionEngineParams, uint32 targetLedger); };