mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Use "Ledger::ref" instead of "const Ledger::pointer&".
This commit is contained in:
@@ -258,7 +258,7 @@ uint256 Ledger::getHash()
|
||||
return(mHash);
|
||||
}
|
||||
|
||||
void Ledger::saveAcceptedLedger(const Ledger::pointer& ledger)
|
||||
void Ledger::saveAcceptedLedger(Ledger::ref ledger)
|
||||
{
|
||||
static boost::format ledgerExists("SELECT LedgerSeq FROM Ledgers where LedgerSeq = %d;");
|
||||
static boost::format deleteLedger("DELETE FROM Ledgers WHERE LedgerSeq = %d;");
|
||||
|
||||
@@ -41,7 +41,8 @@ class Ledger : public boost::enable_shared_from_this<Ledger>
|
||||
{ // The basic Ledger structure, can be opened, closed, or synching
|
||||
friend class TransactionEngine;
|
||||
public:
|
||||
typedef boost::shared_ptr<Ledger> pointer;
|
||||
typedef boost::shared_ptr<Ledger> pointer;
|
||||
typedef const boost::shared_ptr<Ledger>& ref;
|
||||
|
||||
enum TransResult
|
||||
{
|
||||
@@ -161,7 +162,7 @@ public:
|
||||
SLE::pointer getAccountRoot(const NewcoinAddress& naAccountID);
|
||||
|
||||
// database functions
|
||||
static void saveAcceptedLedger(const Ledger::pointer&);
|
||||
static void saveAcceptedLedger(Ledger::ref);
|
||||
static Ledger::pointer loadByIndex(uint32 ledgerIndex);
|
||||
static Ledger::pointer loadByHash(const uint256& ledgerHash);
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ bool LCTransaction::updatePosition(int percentTime, bool proposing)
|
||||
return true;
|
||||
}
|
||||
|
||||
LedgerConsensus::LedgerConsensus(const uint256& prevLCLHash, const Ledger::pointer& previousLedger, uint32 closeTime)
|
||||
LedgerConsensus::LedgerConsensus(const uint256& prevLCLHash, Ledger::ref previousLedger, uint32 closeTime)
|
||||
: mState(lcsPRE_CLOSE), mCloseTime(closeTime), mPrevLedgerHash(prevLCLHash), mPreviousLedger(previousLedger),
|
||||
mCurrentMSeconds(0), mClosePercent(0), mHaveCloseTimeConsensus(false)
|
||||
{
|
||||
@@ -551,6 +551,7 @@ void LedgerConsensus::updateOurPositions()
|
||||
if (it->second->isStale(peerCutoff))
|
||||
{ // proposal is stale
|
||||
uint160 peerID = it->second->getPeerID();
|
||||
Log(lsWARNING) << "Removing stale proposal from " << peerID.GetHex();
|
||||
BOOST_FOREACH(u256_lct_pair& it, mDisputes)
|
||||
it.second->unVote(peerID);
|
||||
mPeerPositions.erase(it++);
|
||||
@@ -870,7 +871,7 @@ void LedgerConsensus::playbackProposals()
|
||||
}
|
||||
|
||||
void LedgerConsensus::applyTransaction(TransactionEngine& engine, const SerializedTransaction::pointer& txn,
|
||||
const Ledger::pointer& ledger, CanonicalTXSet& failedTransactions, bool openLedger)
|
||||
Ledger::ref ledger, CanonicalTXSet& failedTransactions, bool openLedger)
|
||||
{
|
||||
TransactionEngineParams parms = openLedger ? tapOPEN_LEDGER : tapNONE;
|
||||
#ifndef TRUST_NETWORK
|
||||
@@ -902,8 +903,8 @@ void LedgerConsensus::applyTransaction(TransactionEngine& engine, const Serializ
|
||||
#endif
|
||||
}
|
||||
|
||||
void LedgerConsensus::applyTransactions(const SHAMap::pointer& set, const Ledger::pointer& applyLedger,
|
||||
const Ledger::pointer& checkLedger, CanonicalTXSet& failedTransactions, bool openLgr)
|
||||
void LedgerConsensus::applyTransactions(const SHAMap::pointer& set, Ledger::ref applyLedger,
|
||||
Ledger::ref checkLedger, CanonicalTXSet& failedTransactions, bool openLgr)
|
||||
{
|
||||
TransactionEngineParams parms = openLgr ? tapOPEN_LEDGER : tapNONE;
|
||||
TransactionEngine engine(applyLedger);
|
||||
|
||||
@@ -131,10 +131,10 @@ protected:
|
||||
void addPosition(LedgerProposal&, bool ours);
|
||||
void removePosition(LedgerProposal&, bool ours);
|
||||
void sendHaveTxSet(const uint256& set, bool direct);
|
||||
void applyTransactions(const SHAMap::pointer& transactionSet, const Ledger::pointer& targetLedger,
|
||||
const Ledger::pointer& checkLedger, CanonicalTXSet& failedTransactions, bool openLgr);
|
||||
void applyTransactions(const SHAMap::pointer& transactionSet, Ledger::ref targetLedger,
|
||||
Ledger::ref checkLedger, CanonicalTXSet& failedTransactions, bool openLgr);
|
||||
void applyTransaction(TransactionEngine& engine, const SerializedTransaction::pointer& txn,
|
||||
const Ledger::pointer& targetLedger, CanonicalTXSet& failedTransactions, bool openLgr);
|
||||
Ledger::ref targetLedger, CanonicalTXSet& failedTransactions, bool openLgr);
|
||||
|
||||
// manipulating our own position
|
||||
void statusChange(newcoin::NodeEvent, Ledger& ledger);
|
||||
@@ -146,7 +146,7 @@ protected:
|
||||
void endConsensus();
|
||||
|
||||
public:
|
||||
LedgerConsensus(const uint256& prevLCLHash, const Ledger::pointer& previousLedger, uint32 closeTime);
|
||||
LedgerConsensus(const uint256& prevLCLHash, Ledger::ref previousLedger, uint32 closeTime);
|
||||
|
||||
int startup();
|
||||
Json::Value getJson();
|
||||
|
||||
@@ -230,7 +230,7 @@ Json::Value LedgerEntrySet::getJson(int) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
SLE::pointer LedgerEntrySet::getForMod(const uint256& node, Ledger::pointer& ledger,
|
||||
SLE::pointer LedgerEntrySet::getForMod(const uint256& node, Ledger::ref ledger,
|
||||
boost::unordered_map<uint256, SLE::pointer>& newMods)
|
||||
{
|
||||
boost::unordered_map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find(node);
|
||||
@@ -259,7 +259,7 @@ SLE::pointer LedgerEntrySet::getForMod(const uint256& node, Ledger::pointer& led
|
||||
|
||||
}
|
||||
|
||||
bool LedgerEntrySet::threadTx(TransactionMetaNode& metaNode, const NewcoinAddress& threadTo, Ledger::pointer& ledger,
|
||||
bool LedgerEntrySet::threadTx(TransactionMetaNode& metaNode, const NewcoinAddress& threadTo, Ledger::ref ledger,
|
||||
boost::unordered_map<uint256, SLE::pointer>& newMods)
|
||||
{
|
||||
SLE::pointer sle = getForMod(Ledger::getAccountRootIndex(threadTo.getAccountID()), ledger, newMods);
|
||||
@@ -268,7 +268,7 @@ bool LedgerEntrySet::threadTx(TransactionMetaNode& metaNode, const NewcoinAddres
|
||||
return threadTx(metaNode, sle, ledger, newMods);
|
||||
}
|
||||
|
||||
bool LedgerEntrySet::threadTx(TransactionMetaNode& metaNode, SLE::pointer& threadTo, Ledger::pointer& ledger,
|
||||
bool LedgerEntrySet::threadTx(TransactionMetaNode& metaNode, SLE::pointer& threadTo, Ledger::ref ledger,
|
||||
boost::unordered_map<uint256, SLE::pointer>& newMods)
|
||||
{ // node = the node that was modified/deleted/created
|
||||
// threadTo = the node that needs to know
|
||||
@@ -282,7 +282,7 @@ bool LedgerEntrySet::threadTx(TransactionMetaNode& metaNode, SLE::pointer& threa
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LedgerEntrySet::threadOwners(TransactionMetaNode& metaNode, SLE::pointer& node, Ledger::pointer& ledger,
|
||||
bool LedgerEntrySet::threadOwners(TransactionMetaNode& metaNode, SLE::pointer& node, Ledger::ref ledger,
|
||||
boost::unordered_map<uint256, SLE::pointer>& newMods)
|
||||
{ // thread new or modified node to owner or owners
|
||||
if (node->hasOneOwner()) // thread to owner's account
|
||||
@@ -295,7 +295,7 @@ bool LedgerEntrySet::threadOwners(TransactionMetaNode& metaNode, SLE::pointer& n
|
||||
return false;
|
||||
}
|
||||
|
||||
void LedgerEntrySet::calcRawMeta(Serializer& s, Ledger::pointer& origLedger)
|
||||
void LedgerEntrySet::calcRawMeta(Serializer& s, Ledger::ref origLedger)
|
||||
{ // calculate the raw meta data and return it. This must be called before the set is committed
|
||||
|
||||
// Entries modified only as a result of building the transaction metadata
|
||||
|
||||
@@ -38,16 +38,16 @@ protected:
|
||||
LedgerEntrySet(const boost::unordered_map<uint256, LedgerEntrySetEntry> &e, const TransactionMetaSet& s, int m) :
|
||||
mEntries(e), mSet(s), mSeq(m) { ; }
|
||||
|
||||
SLE::pointer getForMod(const uint256& node, Ledger::pointer& ledger,
|
||||
SLE::pointer getForMod(const uint256& node, Ledger::ref ledger,
|
||||
boost::unordered_map<uint256, SLE::pointer>& newMods);
|
||||
|
||||
bool threadTx(TransactionMetaNode& metaNode, const NewcoinAddress& threadTo, Ledger::pointer& ledger,
|
||||
bool threadTx(TransactionMetaNode& metaNode, const NewcoinAddress& threadTo, Ledger::ref ledger,
|
||||
boost::unordered_map<uint256, SLE::pointer>& newMods);
|
||||
|
||||
bool threadTx(TransactionMetaNode& metaNode, SLE::pointer& threadTo, Ledger::pointer& ledger,
|
||||
bool threadTx(TransactionMetaNode& metaNode, SLE::pointer& threadTo, Ledger::ref ledger,
|
||||
boost::unordered_map<uint256, SLE::pointer>& newMods);
|
||||
|
||||
bool threadOwners(TransactionMetaNode& metaNode, SLE::pointer& node, Ledger::pointer& ledger,
|
||||
bool threadOwners(TransactionMetaNode& metaNode, SLE::pointer& node, Ledger::ref ledger,
|
||||
boost::unordered_map<uint256, SLE::pointer>& newMods);
|
||||
|
||||
public:
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
void entryModify(const SLE::pointer&); // This entry will be modified
|
||||
|
||||
Json::Value getJson(int) const;
|
||||
void calcRawMeta(Serializer&, Ledger::pointer& originalLedger);
|
||||
void calcRawMeta(Serializer&, Ledger::ref originalLedger);
|
||||
|
||||
// iterator functions
|
||||
bool isEmpty() const { return mEntries.empty(); }
|
||||
|
||||
@@ -19,7 +19,7 @@ bool LedgerMaster::addHeldTransaction(const Transaction::pointer& transaction)
|
||||
return mHeldTransactionsByID.insert(std::make_pair(transaction->getID(), transaction)).second;
|
||||
}
|
||||
|
||||
void LedgerMaster::pushLedger(const Ledger::pointer& newLedger)
|
||||
void LedgerMaster::pushLedger(Ledger::ref newLedger)
|
||||
{
|
||||
// Caller should already have properly assembled this ledger into "ready-to-close" form --
|
||||
// all candidate transactions must already be appled
|
||||
@@ -35,7 +35,7 @@ void LedgerMaster::pushLedger(const Ledger::pointer& newLedger)
|
||||
mEngine.setLedger(newLedger);
|
||||
}
|
||||
|
||||
void LedgerMaster::pushLedger(const Ledger::pointer& newLCL, const Ledger::pointer& newOL)
|
||||
void LedgerMaster::pushLedger(Ledger::ref newLCL, Ledger::ref newOL)
|
||||
{
|
||||
assert(newLCL->isClosed() && newLCL->isAccepted());
|
||||
assert(!newOL->isClosed() && !newOL->isAccepted());
|
||||
@@ -54,7 +54,7 @@ void LedgerMaster::pushLedger(const Ledger::pointer& newLCL, const Ledger::point
|
||||
mEngine.setLedger(newOL);
|
||||
}
|
||||
|
||||
void LedgerMaster::switchLedgers(const Ledger::pointer& lastClosed, const Ledger::pointer& current)
|
||||
void LedgerMaster::switchLedgers(Ledger::ref lastClosed, Ledger::ref current)
|
||||
{
|
||||
assert(lastClosed && current);
|
||||
mFinalizedLedger = lastClosed;
|
||||
@@ -66,7 +66,7 @@ void LedgerMaster::switchLedgers(const Ledger::pointer& lastClosed, const Ledger
|
||||
mEngine.setLedger(mCurrentLedger);
|
||||
}
|
||||
|
||||
void LedgerMaster::storeLedger(const Ledger::pointer& ledger)
|
||||
void LedgerMaster::storeLedger(Ledger::ref ledger)
|
||||
{
|
||||
mLedgerHistory.addLedger(ledger);
|
||||
}
|
||||
|
||||
@@ -48,11 +48,11 @@ public:
|
||||
TER doTransaction(const SerializedTransaction& txn, uint32 targetLedger,
|
||||
TransactionEngineParams params);
|
||||
|
||||
void pushLedger(const Ledger::pointer& newLedger);
|
||||
void pushLedger(const Ledger::pointer& newLCL, const Ledger::pointer& newOL);
|
||||
void storeLedger(const Ledger::pointer&);
|
||||
void pushLedger(Ledger::ref newLedger);
|
||||
void pushLedger(Ledger::ref newLCL, Ledger::ref newOL);
|
||||
void storeLedger(Ledger::ref);
|
||||
|
||||
void switchLedgers(const Ledger::pointer& lastClosed, const Ledger::pointer& newCurrent);
|
||||
void switchLedgers(Ledger::ref lastClosed, Ledger::ref newCurrent);
|
||||
|
||||
Ledger::pointer closeLedger();
|
||||
|
||||
|
||||
@@ -798,7 +798,7 @@ Json::Value NetworkOPs::getServerInfo()
|
||||
// Monitoring: publisher side
|
||||
//
|
||||
|
||||
Json::Value NetworkOPs::pubBootstrapAccountInfo(const Ledger::pointer& lpAccepted, const NewcoinAddress& naAccountID)
|
||||
Json::Value NetworkOPs::pubBootstrapAccountInfo(Ledger::ref lpAccepted, const NewcoinAddress& naAccountID)
|
||||
{
|
||||
Json::Value jvObj(Json::objectValue);
|
||||
|
||||
@@ -833,7 +833,7 @@ void NetworkOPs::pubAccountInfo(const NewcoinAddress& naAccountID, const Json::V
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkOPs::pubLedger(const Ledger::pointer& lpAccepted)
|
||||
void NetworkOPs::pubLedger(Ledger::ref lpAccepted)
|
||||
{
|
||||
{
|
||||
boost::interprocess::sharable_lock<boost::interprocess::interprocess_upgradable_mutex> sl(mMonitorLock);
|
||||
@@ -946,7 +946,7 @@ Json::Value NetworkOPs::transJson(const SerializedTransaction& stTxn, TER terRes
|
||||
return jvObj;
|
||||
}
|
||||
|
||||
void NetworkOPs::pubTransactionAll(const Ledger::pointer& lpCurrent, const SerializedTransaction& stTxn, TER terResult, const char* pState)
|
||||
void NetworkOPs::pubTransactionAll(Ledger::ref lpCurrent, const SerializedTransaction& stTxn, TER terResult, const char* pState)
|
||||
{
|
||||
Json::Value jvObj = transJson(stTxn, terResult, pState, lpCurrent->getLedgerSeq(), "transaction");
|
||||
|
||||
@@ -956,7 +956,7 @@ void NetworkOPs::pubTransactionAll(const Ledger::pointer& lpCurrent, const Seria
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkOPs::pubTransactionAccounts(const Ledger::pointer& lpCurrent, const SerializedTransaction& stTxn, TER terResult, const char* pState)
|
||||
void NetworkOPs::pubTransactionAccounts(Ledger::ref lpCurrent, const SerializedTransaction& stTxn, TER terResult, const char* pState)
|
||||
{
|
||||
boost::unordered_set<InfoSub*> usisNotify;
|
||||
|
||||
@@ -991,7 +991,7 @@ void NetworkOPs::pubTransactionAccounts(const Ledger::pointer& lpCurrent, const
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkOPs::pubTransaction(const Ledger::pointer& lpCurrent, const SerializedTransaction& stTxn, TER terResult)
|
||||
void NetworkOPs::pubTransaction(Ledger::ref lpCurrent, const SerializedTransaction& stTxn, TER terResult)
|
||||
{
|
||||
boost::interprocess::sharable_lock<boost::interprocess::interprocess_upgradable_mutex> sl(mMonitorLock);
|
||||
|
||||
|
||||
@@ -78,10 +78,10 @@ protected:
|
||||
void setMode(OperatingMode);
|
||||
|
||||
Json::Value transJson(const SerializedTransaction& stTxn, TER terResult, const std::string& strStatus, int iSeq, const std::string& strType);
|
||||
void pubTransactionAll(const Ledger::pointer& lpCurrent, const SerializedTransaction& stTxn, TER terResult, const char* pState);
|
||||
void pubTransactionAccounts(const Ledger::pointer& lpCurrent, const SerializedTransaction& stTxn, TER terResult, const char* pState);
|
||||
void pubTransactionAll(Ledger::ref lpCurrent, const SerializedTransaction& stTxn, TER terResult, const char* pState);
|
||||
void pubTransactionAccounts(Ledger::ref lpCurrent, const SerializedTransaction& stTxn, TER terResult, const char* pState);
|
||||
|
||||
Json::Value pubBootstrapAccountInfo(const Ledger::pointer& lpAccepted, const NewcoinAddress& naAccountID);
|
||||
Json::Value pubBootstrapAccountInfo(Ledger::ref lpAccepted, const NewcoinAddress& naAccountID);
|
||||
|
||||
public:
|
||||
NetworkOPs(boost::asio::io_service& io_service, LedgerMaster* pLedgerMaster);
|
||||
@@ -195,8 +195,8 @@ public:
|
||||
//
|
||||
|
||||
void pubAccountInfo(const NewcoinAddress& naAccountID, const Json::Value& jvObj);
|
||||
void pubLedger(const Ledger::pointer& lpAccepted);
|
||||
void pubTransaction(const Ledger::pointer& lpLedger, const SerializedTransaction& stTxn, TER terResult);
|
||||
void pubLedger(Ledger::ref lpAccepted);
|
||||
void pubTransaction(Ledger::ref lpLedger, const SerializedTransaction& stTxn, TER terResult);
|
||||
|
||||
//
|
||||
// Monitoring: subscriber side
|
||||
|
||||
10
src/Peer.h
10
src/Peer.h
@@ -141,19 +141,19 @@ public:
|
||||
bool samePeer(const Peer& p) { return this == &p; }
|
||||
|
||||
void sendPacket(const PackedMessage::pointer& packet);
|
||||
void sendLedgerProposal(const Ledger::pointer& ledger);
|
||||
void sendFullLedger(const Ledger::pointer& ledger);
|
||||
void sendLedgerProposal(Ledger::ref ledger);
|
||||
void sendFullLedger(Ledger::ref ledger);
|
||||
void sendGetFullLedger(uint256& hash);
|
||||
void sendGetPeers();
|
||||
|
||||
void punishPeer(PeerPunish pp);
|
||||
|
||||
Json::Value getJson();
|
||||
bool isConnected() const { return mHelloed && !mDetaching; }
|
||||
bool isConnected() const { return mHelloed && !mDetaching; }
|
||||
|
||||
uint256 getClosedLedgerHash() const { return mClosedLedgerHash; }
|
||||
uint256 getClosedLedgerHash() const { return mClosedLedgerHash; }
|
||||
bool hasLedger(const uint256& hash) const;
|
||||
NewcoinAddress getNodePublic() const { return mNodePublic; }
|
||||
NewcoinAddress getNodePublic() const { return mNodePublic; }
|
||||
void cycleStatus() { mPreviousLedgerHash = mClosedLedgerHash; mClosedLedgerHash.zero(); }
|
||||
};
|
||||
|
||||
|
||||
@@ -3691,7 +3691,7 @@ TER PathState::pushNode(int iType, uint160 uAccountID, uint160 uCurrencyID, uint
|
||||
}
|
||||
|
||||
PathState::PathState(
|
||||
const Ledger::pointer& lpLedger,
|
||||
Ledger::ref lpLedger,
|
||||
const int iIndex,
|
||||
const LedgerEntrySet& lesSource,
|
||||
const STPath& spSourcePath,
|
||||
|
||||
@@ -202,7 +202,7 @@ public:
|
||||
STAmount saOutAct; // Amount actually sent (calc output).
|
||||
|
||||
PathState(
|
||||
const Ledger::pointer& lpLedger,
|
||||
Ledger::ref lpLedger,
|
||||
const int iIndex,
|
||||
const LedgerEntrySet& lesSource,
|
||||
const STPath& spSourcePath,
|
||||
@@ -216,7 +216,7 @@ public:
|
||||
Json::Value getJson() const;
|
||||
|
||||
static PathState::pointer createPathState(
|
||||
const Ledger::pointer& lpLedger,
|
||||
Ledger::ref lpLedger,
|
||||
const int iIndex,
|
||||
const LedgerEntrySet& lesSource,
|
||||
const STPath& spSourcePath,
|
||||
@@ -337,10 +337,10 @@ protected:
|
||||
|
||||
public:
|
||||
TransactionEngine() { ; }
|
||||
TransactionEngine(const Ledger::pointer& ledger) : mLedger(ledger) { assert(mLedger); }
|
||||
TransactionEngine(Ledger::ref ledger) : mLedger(ledger) { assert(mLedger); }
|
||||
|
||||
Ledger::pointer getLedger() { return mLedger; }
|
||||
void setLedger(const Ledger::pointer& ledger) { assert(ledger); mLedger = ledger; }
|
||||
Ledger::pointer getLedger() { return mLedger; }
|
||||
void setLedger(Ledger::ref ledger) { assert(ledger); mLedger = ledger; }
|
||||
|
||||
TER applyTransaction(const SerializedTransaction&, TransactionEngineParams);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user