Pass by reference in processTransaction

This commit is contained in:
Miguel Portilla
2015-07-09 13:24:29 -04:00
committed by Vinnie Falco
parent d8d51e8103
commit de6f678de7
6 changed files with 14 additions and 23 deletions

View File

@@ -213,7 +213,7 @@ public:
void submitTransaction (Job&, STTx::pointer) override; void submitTransaction (Job&, STTx::pointer) override;
void processTransaction ( void processTransaction (
Transaction::pointer transaction, Transaction::pointer& transaction,
bool bAdmin, bool bLocal, FailHard failType) override; bool bAdmin, bool bLocal, FailHard failType) override;
/** /**
@@ -858,7 +858,7 @@ void NetworkOPsImp::submitTransaction (Job&, STTx::pointer iTrans)
FailHard::no)); FailHard::no));
} }
void NetworkOPsImp::processTransaction (Transaction::pointer transaction, void NetworkOPsImp::processTransaction (Transaction::pointer& transaction,
bool bAdmin, bool bLocal, FailHard failType) bool bAdmin, bool bLocal, FailHard failType)
{ {
auto ev = m_job_queue.getLoadEventAP (jtTXN_PROC, "ProcessTXN"); auto ev = m_job_queue.getLoadEventAP (jtTXN_PROC, "ProcessTXN");
@@ -1105,7 +1105,6 @@ void NetworkOPsImp::apply (std::unique_lock<std::mutex>& batchLock)
// transaction should be held // transaction should be held
m_journal.debug << "Transaction should be held: " << e.result; m_journal.debug << "Transaction should be held: " << e.result;
e.transaction->setStatus (HELD); e.transaction->setStatus (HELD);
getApp().getMasterTransaction().canonicalize (&e.transaction);
m_ledgerMaster.addHeldTransaction (e.transaction); m_ledgerMaster.addHeldTransaction (e.transaction);
} }
} }

View File

@@ -143,7 +143,7 @@ public:
* @param bLocal Client submission. * @param bLocal Client submission.
* @param failType fail_hard setting from transaction submission. * @param failType fail_hard setting from transaction submission.
*/ */
virtual void processTransaction (Transaction::pointer transaction, virtual void processTransaction (Transaction::pointer& transaction,
bool bAdmin, bool bLocal, FailHard failType) = 0; bool bAdmin, bool bLocal, FailHard failType) = 0;
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------

View File

@@ -39,7 +39,7 @@ public:
// return value: true = we had the transaction already // return value: true = we had the transaction already
bool inLedger (uint256 const& hash, std::uint32_t ledger); bool inLedger (uint256 const& hash, std::uint32_t ledger);
bool canonicalize (Transaction::pointer* pTransaction); void canonicalize (Transaction::pointer* pTransaction);
void sweep (void); void sweep (void);
TaggedCache <uint256, Transaction>& getCache(); TaggedCache <uint256, Transaction>& getCache();

View File

@@ -91,25 +91,17 @@ STTx::pointer TransactionMaster::fetch (std::shared_ptr<SHAMapItem> const& item,
return txn; return txn;
} }
bool TransactionMaster::canonicalize (Transaction::pointer* pTransaction) void
TransactionMaster::canonicalize(Transaction::pointer* pTransaction)
{ {
Transaction::pointer txn (*pTransaction); uint256 const tid = (*pTransaction)->getID();
if (tid != zero)
uint256 tid = txn->getID ();
if (!tid)
return false;
// VFALCO NOTE canonicalize can change the value of txn!
if (mCache.canonicalize (tid, txn))
{ {
Transaction::pointer txn(*pTransaction);
// VFALCO NOTE canonicalize can change the value of txn!
mCache.canonicalize(tid, txn);
*pTransaction = txn; *pTransaction = txn;
return true;
} }
// VFALCO NOTE I am unsure if this is necessary but better safe than sorry.
*pTransaction = txn;
return false;
} }
void TransactionMaster::sweep (void) void TransactionMaster::sweep (void)

View File

@@ -132,7 +132,7 @@ std::uint32_t TxnSignApiFacade::getSeq () const
} }
void TxnSignApiFacade::processTransaction ( void TxnSignApiFacade::processTransaction (
Transaction::ref tpTrans, Transaction::pointer& transaction,
bool bAdmin, bool bAdmin,
bool bLocal, bool bLocal,
NetworkOPs::FailHard failType) NetworkOPs::FailHard failType)
@@ -140,7 +140,7 @@ void TxnSignApiFacade::processTransaction (
if (!netOPs_) // Unit testing. if (!netOPs_) // Unit testing.
return; return;
netOPs_->processTransaction (tpTrans, bAdmin, bLocal, failType); netOPs_->processTransaction(transaction, bAdmin, bLocal, failType);
} }
bool TxnSignApiFacade::findPathsForOneIssuer ( bool TxnSignApiFacade::findPathsForOneIssuer (

View File

@@ -76,7 +76,7 @@ public:
STPath& fullLiquidityPath) const; STPath& fullLiquidityPath) const;
void processTransaction ( void processTransaction (
Transaction::ref tpTrans, Transaction::pointer& transaction,
bool bAdmin, bool bAdmin,
bool bLocal, bool bLocal,
NetworkOPs::FailHard failType); NetworkOPs::FailHard failType);