From 2b5142ee4dac51133d87d5a29f24022ede876861 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Tue, 11 Mar 2014 03:28:12 -0700 Subject: [PATCH] Make transaction forwarding less promiscuous --- src/ripple_app/misc/NetworkOPs.cpp | 22 +++++++++++----------- src/ripple_app/misc/NetworkOPs.h | 6 +++--- src/ripple_app/rpc/RPCHandler.cpp | 4 ++-- src/ripple_overlay/impl/PeerImp.h | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/ripple_app/misc/NetworkOPs.cpp b/src/ripple_app/misc/NetworkOPs.cpp index 5b7f203fd..d24acb460 100644 --- a/src/ripple_app/misc/NetworkOPs.cpp +++ b/src/ripple_app/misc/NetworkOPs.cpp @@ -148,20 +148,20 @@ public: // typedef std::function stCallback; // must complete immediately void submitTransaction (Job&, SerializedTransaction::pointer, stCallback callback = stCallback ()); - Transaction::pointer submitTransactionSync (Transaction::ref tpTrans, bool bAdmin, bool bFailHard, bool bSubmit); + Transaction::pointer submitTransactionSync (Transaction::ref tpTrans, bool bAdmin, bool bLocal, bool bFailHard, bool bSubmit); void runTransactionQueue (); - Transaction::pointer processTransactionCb (Transaction::pointer, bool bAdmin, bool bFailHard, stCallback); - Transaction::pointer processTransaction (Transaction::pointer transaction, bool bAdmin, bool bFailHard) + Transaction::pointer processTransactionCb (Transaction::pointer, bool bAdmin, bool bLocal, bool bFailHard, stCallback); + Transaction::pointer processTransaction (Transaction::pointer transaction, bool bAdmin, bool bLocal, bool bFailHard) { - return processTransactionCb (transaction, bAdmin, bFailHard, stCallback ()); + return processTransactionCb (transaction, bAdmin, bLocal, bFailHard, stCallback ()); } // VFALCO Workaround for MSVC std::function which doesn't swallow return types. // - void processTransactionCbVoid (Transaction::pointer p, bool bAdmin, bool bFailHard, stCallback cb) + void processTransactionCbVoid (Transaction::pointer p, bool bAdmin, bool bLocal, bool bFailHard, stCallback cb) { - processTransactionCb (p, bAdmin, bFailHard, cb); + processTransactionCb (p, bAdmin, bLocal, bFailHard, cb); } Transaction::pointer findTransactionByID (uint256 const& transactionID); @@ -751,12 +751,12 @@ void NetworkOPsImp::submitTransaction (Job&, SerializedTransaction::pointer iTra getApp().getJobQueue().addJob (jtTRANSACTION, "submitTxn", std::bind (&NetworkOPsImp::processTransactionCbVoid, this, - boost::make_shared (trans, false), false, false, callback)); + boost::make_shared (trans, false), false, false, false, callback)); } // Sterilize transaction through serialization. // This is fully synchronous and deprecated -Transaction::pointer NetworkOPsImp::submitTransactionSync (Transaction::ref tpTrans, bool bAdmin, bool bFailHard, bool bSubmit) +Transaction::pointer NetworkOPsImp::submitTransactionSync (Transaction::ref tpTrans, bool bAdmin, bool bLocal, bool bFailHard, bool bSubmit) { Serializer s; tpTrans->getSTransaction ()->add (s); @@ -771,7 +771,7 @@ Transaction::pointer NetworkOPsImp::submitTransactionSync (Transaction::ref tpTr else if (tpTransNew->getSTransaction ()->isEquivalent (*tpTrans->getSTransaction ())) { if (bSubmit) - (void) NetworkOPsImp::processTransaction (tpTransNew, bAdmin, bFailHard); + (void) NetworkOPsImp::processTransaction (tpTransNew, bAdmin, bLocal, bFailHard); } else { @@ -875,7 +875,7 @@ void NetworkOPsImp::runTransactionQueue () } Transaction::pointer NetworkOPsImp::processTransactionCb ( - Transaction::pointer trans, bool bAdmin, bool bFailHard, stCallback callback) + Transaction::pointer trans, bool bAdmin, bool bLocal, bool bFailHard, stCallback callback) { LoadEvent::autoptr ev = getApp().getJobQueue ().getLoadEventAP (jtTXN_PROC, "ProcessTXN"); @@ -968,7 +968,7 @@ Transaction::pointer NetworkOPsImp::processTransactionCb ( trans->setStatus (INVALID); } - if (didApply || ((mMode != omFULL) && !bFailHard)) + if (didApply || ((mMode != omFULL) && !bFailHard && bLocal)) { std::set peers; diff --git a/src/ripple_app/misc/NetworkOPs.h b/src/ripple_app/misc/NetworkOPs.h index 03e6fae76..feb982a9d 100644 --- a/src/ripple_app/misc/NetworkOPs.h +++ b/src/ripple_app/misc/NetworkOPs.h @@ -141,12 +141,12 @@ public: virtual void submitTransaction (Job&, SerializedTransaction::pointer, stCallback callback = stCallback ()) = 0; virtual Transaction::pointer submitTransactionSync (Transaction::ref tpTrans, - bool bAdmin, bool bFailHard, bool bSubmit) = 0; + bool bAdmin, bool bLocal, bool bFailHard, bool bSubmit) = 0; virtual void runTransactionQueue () = 0; virtual Transaction::pointer processTransactionCb (Transaction::pointer, - bool bAdmin, bool bFailHard, stCallback) = 0; + bool bAdmin, bool bLocal, bool bFailHard, stCallback) = 0; virtual Transaction::pointer processTransaction (Transaction::pointer transaction, - bool bAdmin, bool bFailHard) = 0; + bool bAdmin, bool bLocal, bool bFailHard) = 0; virtual Transaction::pointer findTransactionByID (uint256 const& transactionID) = 0; virtual int findTransactionsByDestination (std::list&, const RippleAddress& destinationAccount, uint32 startLedgerSeq, diff --git a/src/ripple_app/rpc/RPCHandler.cpp b/src/ripple_app/rpc/RPCHandler.cpp index 85374fc90..e8e109519 100644 --- a/src/ripple_app/rpc/RPCHandler.cpp +++ b/src/ripple_app/rpc/RPCHandler.cpp @@ -470,7 +470,7 @@ Json::Value RPCHandler::transactionSign (Json::Value params, { // FIXME: For performance, should use asynch interface tpTrans = mNetOps->submitTransactionSync (tpTrans, - mRole == Config::ADMIN, bFailHard, bSubmit); + mRole == Config::ADMIN, true, bFailHard, bSubmit); if (!tpTrans) { @@ -2046,7 +2046,7 @@ Json::Value RPCHandler::doSubmit (Json::Value params, Resource::Charge& loadType try { - (void) mNetOps->processTransaction (tpTrans, mRole == Config::ADMIN, + (void) mNetOps->processTransaction (tpTrans, mRole == Config::ADMIN, true, params.isMember ("fail_hard") && params["fail_hard"].asBool ()); } catch (std::exception& e) diff --git a/src/ripple_overlay/impl/PeerImp.h b/src/ripple_overlay/impl/PeerImp.h index a8c013f96..fb9dff050 100644 --- a/src/ripple_overlay/impl/PeerImp.h +++ b/src/ripple_overlay/impl/PeerImp.h @@ -2623,7 +2623,7 @@ private: else getApp().getHashRouter ().setFlag (stx->getTransactionID (), SF_SIGGOOD); - getApp().getOPs ().processTransaction (tx, isSetBit (flags, SF_TRUSTED), false); + getApp().getOPs ().processTransaction (tx, isSetBit (flags, SF_TRUSTED), false, false); #ifndef TRUST_NETWORK }