From 6c016039c2d7c55fa7809a7002d0ebea98bfe74d Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Thu, 13 Sep 2012 15:36:56 -0700 Subject: [PATCH] Get rid of all "const SHAMap::pointer&" -> SHAMap::ref --- src/LedgerConsensus.cpp | 10 +++++----- src/LedgerConsensus.h | 10 +++++----- src/NetworkOPs.cpp | 2 +- src/NetworkOPs.h | 2 +- src/SHAMap.h | 6 ++++-- src/SHAMapDiff.cpp | 2 +- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/LedgerConsensus.cpp b/src/LedgerConsensus.cpp index 31f5812015..5e10b5f78f 100644 --- a/src/LedgerConsensus.cpp +++ b/src/LedgerConsensus.cpp @@ -374,7 +374,7 @@ void LedgerConsensus::takeInitialPosition(Ledger& initialLedger) propose(); } -void LedgerConsensus::createDisputes(const SHAMap::pointer& m1, const SHAMap::pointer& m2) +void LedgerConsensus::createDisputes(SHAMap::ref m1, SHAMap::ref m2) { SHAMap::SHAMapDiff differences; m1->compare(m2, differences, 16384); @@ -394,7 +394,7 @@ void LedgerConsensus::createDisputes(const SHAMap::pointer& m1, const SHAMap::po } } -void LedgerConsensus::mapComplete(const uint256& hash, const SHAMap::pointer& map, bool acquired) +void LedgerConsensus::mapComplete(const uint256& hash, SHAMap::ref map, bool acquired) { if (acquired) Log(lsINFO) << "We have acquired TXS " << hash; @@ -446,7 +446,7 @@ void LedgerConsensus::sendHaveTxSet(const uint256& hash, bool direct) theApp->getConnectionPool().relayMessage(NULL, packet); } -void LedgerConsensus::adjustCount(const SHAMap::pointer& map, const std::vector& peers) +void LedgerConsensus::adjustCount(SHAMap::ref map, const std::vector& peers) { // Adjust the counts on all disputed transactions based on the set of peers taking this position BOOST_FOREACH(u256_lct_pair& it, mDisputes) { @@ -954,7 +954,7 @@ void LedgerConsensus::applyTransaction(TransactionEngine& engine, const Serializ #endif } -void LedgerConsensus::applyTransactions(const SHAMap::pointer& set, Ledger::ref applyLedger, +void LedgerConsensus::applyTransactions(SHAMap::ref set, Ledger::ref applyLedger, Ledger::ref checkLedger, CanonicalTXSet& failedTransactions, bool openLgr) { TransactionEngineParams parms = openLgr ? tapOPEN_LEDGER : tapNONE; @@ -1016,7 +1016,7 @@ uint32 LedgerConsensus::roundCloseTime(uint32 closeTime) return closeTime - (closeTime % mCloseResolution); } -void LedgerConsensus::accept(const SHAMap::pointer& set) +void LedgerConsensus::accept(SHAMap::ref set) { assert(set->getHash() == mOurPosition->getCurrentHash()); diff --git a/src/LedgerConsensus.h b/src/LedgerConsensus.h index 17aa02691d..fcec2205a5 100644 --- a/src/LedgerConsensus.h +++ b/src/LedgerConsensus.h @@ -120,21 +120,21 @@ protected: // final accept logic static void Saccept(boost::shared_ptr This, SHAMap::pointer txSet); - void accept(const SHAMap::pointer& txSet); + void accept(SHAMap::ref txSet); void weHave(const uint256& id, Peer::ref avoidPeer); void startAcquiring(const TransactionAcquire::pointer&); SHAMap::pointer find(const uint256& hash); - void createDisputes(const SHAMap::pointer&, const SHAMap::pointer&); + void createDisputes(SHAMap::ref, SHAMap::ref); void addDisputedTransaction(const uint256&, const std::vector& transaction); - void adjustCount(const SHAMap::pointer& map, const std::vector& peers); + void adjustCount(SHAMap::ref map, const std::vector& peers); void propose(); void addPosition(LedgerProposal&, bool ours); void removePosition(LedgerProposal&, bool ours); void sendHaveTxSet(const uint256& set, bool direct); - void applyTransactions(const SHAMap::pointer& transactionSet, Ledger::ref targetLedger, + void applyTransactions(SHAMap::ref transactionSet, Ledger::ref targetLedger, Ledger::ref checkLedger, CanonicalTXSet& failedTransactions, bool openLgr); void applyTransaction(TransactionEngine& engine, const SerializedTransaction::pointer& txn, Ledger::ref targetLedger, CanonicalTXSet& failedTransactions, bool openLgr); @@ -162,7 +162,7 @@ public: SHAMap::pointer getTransactionTree(const uint256& hash, bool doAcquire); TransactionAcquire::pointer getAcquiring(const uint256& hash); - void mapComplete(const uint256& hash, const SHAMap::pointer& map, bool acquired); + void mapComplete(const uint256& hash, SHAMap::ref map, bool acquired); void checkLCL(); void handleLCL(const uint256& lclHash); diff --git a/src/NetworkOPs.cpp b/src/NetworkOPs.cpp index cf3873ba89..159a7a2d69 100644 --- a/src/NetworkOPs.cpp +++ b/src/NetworkOPs.cpp @@ -712,7 +712,7 @@ bool NetworkOPs::hasTXSet(const boost::shared_ptr& peer, const uint256& se return mConsensus->peerHasSet(peer, set, status); } -void NetworkOPs::mapComplete(const uint256& hash, const SHAMap::pointer& map) +void NetworkOPs::mapComplete(const uint256& hash, SHAMap::ref map) { if (mConsensus) mConsensus->mapComplete(hash, map, true); diff --git a/src/NetworkOPs.h b/src/NetworkOPs.h index 04f4e731ae..970a27c633 100644 --- a/src/NetworkOPs.h +++ b/src/NetworkOPs.h @@ -171,7 +171,7 @@ public: bool recvValidation(const SerializedValidation::pointer& val); SHAMap::pointer getTXMap(const uint256& hash); bool hasTXSet(const boost::shared_ptr& peer, const uint256& set, newcoin::TxSetStatus status); - void mapComplete(const uint256& hash, const SHAMap::pointer& map); + void mapComplete(const uint256& hash, SHAMap::ref& map); // network state machine void checkState(const boost::system::error_code& result); diff --git a/src/SHAMap.h b/src/SHAMap.h index 09ccefe738..08712611f7 100644 --- a/src/SHAMap.h +++ b/src/SHAMap.h @@ -24,7 +24,8 @@ class SHAMap; class SHAMapNode { // Identifies a node in a SHA256 hash public: - typedef boost::shared_ptr pointer; + typedef boost::shared_ptr pointer; + typedef const boost::shared_ptr& ref; private: static uint256 smMasks[65]; // AND with hash to get node id @@ -255,6 +256,7 @@ class SHAMap { public: typedef boost::shared_ptr pointer; + typedef const boost::shared_ptr& ref; typedef std::map > SHAMapDiff; private: @@ -350,7 +352,7 @@ public: // caution: otherMap must be accessed only by this function // return value: true=successfully completed, false=too different - bool compare(const SHAMap::pointer& otherMap, SHAMapDiff& differences, int maxCount); + bool compare(SHAMap::ref otherMap, SHAMapDiff& differences, int maxCount); void armDirty(); int flushDirty(int maxNodes, HashedObjectType t, uint32 seq); diff --git a/src/SHAMapDiff.cpp b/src/SHAMapDiff.cpp index b425c1e7e6..9c147ac80e 100644 --- a/src/SHAMapDiff.cpp +++ b/src/SHAMapDiff.cpp @@ -91,7 +91,7 @@ bool SHAMap::walkBranch(SHAMapTreeNode* node, SHAMapItem::pointer otherMapItem, return true; } -bool SHAMap::compare(const SHAMap::pointer& otherMap, SHAMapDiff& differences, int maxCount) +bool SHAMap::compare(SHAMap::ref otherMap, SHAMapDiff& differences, int maxCount) { // compare two hash trees, add up to maxCount differences to the difference table // return value: true=complete table of differences given, false=too many differences // throws on corrupt tables or missing nodes