Get rid of all "const SHAMap::pointer&" -> SHAMap::ref

This commit is contained in:
JoelKatz
2012-09-13 15:36:56 -07:00
parent 7c7a4bd3e0
commit 6c016039c2
6 changed files with 17 additions and 15 deletions

View File

@@ -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<uint160>& peers)
void LedgerConsensus::adjustCount(SHAMap::ref map, const std::vector<uint160>& 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());

View File

@@ -120,21 +120,21 @@ protected:
// final accept logic
static void Saccept(boost::shared_ptr<LedgerConsensus> 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<unsigned char>& transaction);
void adjustCount(const SHAMap::pointer& map, const std::vector<uint160>& peers);
void adjustCount(SHAMap::ref map, const std::vector<uint160>& 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);

View File

@@ -712,7 +712,7 @@ bool NetworkOPs::hasTXSet(const boost::shared_ptr<Peer>& 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);

View File

@@ -171,7 +171,7 @@ public:
bool recvValidation(const SerializedValidation::pointer& val);
SHAMap::pointer getTXMap(const uint256& hash);
bool hasTXSet(const boost::shared_ptr<Peer>& 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);

View File

@@ -24,7 +24,8 @@ class SHAMap;
class SHAMapNode
{ // Identifies a node in a SHA256 hash
public:
typedef boost::shared_ptr<SHAMapNode> pointer;
typedef boost::shared_ptr<SHAMapNode> pointer;
typedef const boost::shared_ptr<SHAMapNode>& ref;
private:
static uint256 smMasks[65]; // AND with hash to get node id
@@ -255,6 +256,7 @@ class SHAMap
{
public:
typedef boost::shared_ptr<SHAMap> pointer;
typedef const boost::shared_ptr<SHAMap>& ref;
typedef std::map<uint256, std::pair<SHAMapItem::pointer, SHAMapItem::pointer> > 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);

View File

@@ -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