mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 22:45:52 +00:00
Lots of small cleanups.
This commit is contained in:
@@ -37,7 +37,7 @@ bool CanonicalTXKey::operator>=(const CanonicalTXKey& key)const
|
||||
return mTXid >= key.mTXid;
|
||||
}
|
||||
|
||||
void CanonicalTXSet::push_back(const SerializedTransaction::pointer& txn)
|
||||
void CanonicalTXSet::push_back(SerializedTransaction::ref txn)
|
||||
{
|
||||
uint256 effectiveAccount = mSetHash;
|
||||
effectiveAccount ^= txn->getSourceAccount().getAccountID().to256();
|
||||
|
||||
@@ -38,7 +38,7 @@ protected:
|
||||
public:
|
||||
CanonicalTXSet(const uint256& lclHash) : mSetHash(lclHash) { ; }
|
||||
|
||||
void push_back(const SerializedTransaction::pointer& txn);
|
||||
void push_back(SerializedTransaction::ref txn);
|
||||
iterator erase(const iterator& it);
|
||||
|
||||
iterator begin() { return mMap.begin(); }
|
||||
|
||||
@@ -993,7 +993,7 @@ void LedgerConsensus::playbackProposals()
|
||||
}
|
||||
}
|
||||
|
||||
void LedgerConsensus::applyTransaction(TransactionEngine& engine, const SerializedTransaction::pointer& txn,
|
||||
void LedgerConsensus::applyTransaction(TransactionEngine& engine, SerializedTransaction::ref txn,
|
||||
Ledger::ref ledger, CanonicalTXSet& failedTransactions, bool openLedger)
|
||||
{
|
||||
TransactionEngineParams parms = openLedger ? tapOPEN_LEDGER : tapNONE;
|
||||
|
||||
@@ -134,7 +134,7 @@ protected:
|
||||
void sendHaveTxSet(const uint256& set, bool direct);
|
||||
void applyTransactions(SHAMap::ref transactionSet, Ledger::ref targetLedger,
|
||||
Ledger::ref checkLedger, CanonicalTXSet& failedTransactions, bool openLgr);
|
||||
void applyTransaction(TransactionEngine& engine, const SerializedTransaction::pointer& txn,
|
||||
void applyTransaction(TransactionEngine& engine, SerializedTransaction::ref txn,
|
||||
Ledger::ref targetLedger, CanonicalTXSet& failedTransactions, bool openLgr);
|
||||
|
||||
uint32 roundCloseTime(uint32 closeTime);
|
||||
|
||||
@@ -65,8 +65,8 @@ public:
|
||||
void init(Ledger::ref ledger, const uint256& transactionID, uint32 ledgerID);
|
||||
void clear();
|
||||
|
||||
Ledger::pointer& getLedger() { return mLedger; }
|
||||
const Ledger::pointer& getLedgerRef() const { return mLedger; }
|
||||
Ledger::pointer& getLedger() { return mLedger; }
|
||||
Ledger::ref getLedgerRef() const { return mLedger; }
|
||||
|
||||
// basic entry functions
|
||||
SLE::pointer getEntry(const uint256& index, LedgerEntryAction&);
|
||||
|
||||
@@ -638,7 +638,7 @@ void NetworkOPs::switchLastClosedLedger(Ledger::pointer newLedger, bool duringCo
|
||||
theApp->getConnectionPool().relayMessage(NULL, packet);
|
||||
}
|
||||
|
||||
int NetworkOPs::beginConsensus(const uint256& networkClosed, Ledger::pointer closingLedger)
|
||||
int NetworkOPs::beginConsensus(const uint256& networkClosed, Ledger::ref closingLedger)
|
||||
{
|
||||
cLog(lsINFO) << "Consensus time for ledger " << closingLedger->getLedgerSeq();
|
||||
cLog(lsINFO) << " LCL is " << closingLedger->getParentHash();
|
||||
|
||||
@@ -180,7 +180,7 @@ public:
|
||||
void checkState(const boost::system::error_code& result);
|
||||
void switchLastClosedLedger(Ledger::pointer newLedger, bool duringConsensus); // Used for the "jump" case
|
||||
bool checkLastClosedLedger(const std::vector<Peer::pointer>&, uint256& networkClosed);
|
||||
int beginConsensus(const uint256& networkClosed, Ledger::pointer closingLedger);
|
||||
int beginConsensus(const uint256& networkClosed, Ledger::ref closingLedger);
|
||||
void endConsensus(bool correctLCL);
|
||||
void setStandAlone() { setMode(omFULL); }
|
||||
void setStateTimer();
|
||||
|
||||
@@ -27,7 +27,7 @@ std::size_t hash_value(const aciSource& asValue)
|
||||
// <-- uOfferIndex : 0=end of list.
|
||||
TER RippleCalc::calcNodeAdvance(
|
||||
const unsigned int uIndex, // 0 < uIndex < uLast
|
||||
const PathState::pointer& pspCur,
|
||||
PathState::ref pspCur,
|
||||
const bool bMultiQuality,
|
||||
const bool bReverse)
|
||||
{
|
||||
@@ -267,7 +267,7 @@ TER RippleCalc::calcNodeAdvance(
|
||||
// Continue process till request is satisified while we the rate does not increase past the initial rate.
|
||||
TER RippleCalc::calcNodeDeliverRev(
|
||||
const unsigned int uIndex, // 0 < uIndex < uLast
|
||||
const PathState::pointer& pspCur,
|
||||
PathState::ref pspCur,
|
||||
const bool bMultiQuality,
|
||||
const uint160& uOutAccountID, // --> Output owner's account.
|
||||
const STAmount& saOutReq, // --> Funds wanted.
|
||||
@@ -459,7 +459,7 @@ TER RippleCalc::calcNodeDeliverRev(
|
||||
// Goal: Make progress consuming the offer.
|
||||
TER RippleCalc::calcNodeDeliverFwd(
|
||||
const unsigned int uIndex, // 0 < uIndex < uLast
|
||||
const PathState::pointer& pspCur,
|
||||
PathState::ref pspCur,
|
||||
const bool bMultiQuality,
|
||||
const uint160& uInAccountID, // --> Input owner's account.
|
||||
const STAmount& saInFunds, // --> Funds available for delivery and fees.
|
||||
@@ -610,7 +610,7 @@ TER RippleCalc::calcNodeDeliverFwd(
|
||||
// Called to drive from the last offer node in a chain.
|
||||
TER RippleCalc::calcNodeOfferRev(
|
||||
const unsigned int uIndex, // 0 < uIndex < uLast
|
||||
const PathState::pointer& pspCur,
|
||||
PathState::ref pspCur,
|
||||
const bool bMultiQuality)
|
||||
{
|
||||
TER terResult;
|
||||
@@ -650,7 +650,7 @@ TER RippleCalc::calcNodeOfferRev(
|
||||
// - Deliver is set without transfer fees.
|
||||
TER RippleCalc::calcNodeOfferFwd(
|
||||
const unsigned int uIndex, // 0 < uIndex < uLast
|
||||
const PathState::pointer& pspCur,
|
||||
PathState::ref pspCur,
|
||||
const bool bMultiQuality
|
||||
)
|
||||
{
|
||||
@@ -789,7 +789,7 @@ void RippleCalc::calcNodeRipple(
|
||||
|
||||
// Calculate saPrvRedeemReq, saPrvIssueReq, saPrvDeliver from saCur...
|
||||
// <-- tesSUCCESS or tepPATH_DRY
|
||||
TER RippleCalc::calcNodeAccountRev(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality)
|
||||
TER RippleCalc::calcNodeAccountRev(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality)
|
||||
{
|
||||
TER terResult = tesSUCCESS;
|
||||
const unsigned int uLast = pspCur->vpnNodes.size() - 1;
|
||||
@@ -1100,7 +1100,7 @@ TER RippleCalc::calcNodeAccountRev(const unsigned int uIndex, const PathState::p
|
||||
// - Output to next node is computed as input minus quality or transfer fee.
|
||||
TER RippleCalc::calcNodeAccountFwd(
|
||||
const unsigned int uIndex, // 0 <= uIndex <= uLast
|
||||
const PathState::pointer& pspCur,
|
||||
PathState::ref pspCur,
|
||||
const bool bMultiQuality)
|
||||
{
|
||||
TER terResult = tesSUCCESS;
|
||||
@@ -1362,7 +1362,7 @@ TER RippleCalc::calcNodeAccountFwd(
|
||||
}
|
||||
|
||||
// Return true, iff lhs has less priority than rhs.
|
||||
bool PathState::lessPriority(const PathState::pointer& lhs, const PathState::pointer& rhs)
|
||||
bool PathState::lessPriority(PathState::ref lhs, PathState::ref rhs)
|
||||
{
|
||||
if (lhs->uQuality != rhs->uQuality)
|
||||
return lhs->uQuality > rhs->uQuality; // Bigger is worse.
|
||||
@@ -1713,7 +1713,7 @@ Json::Value PathState::getJson() const
|
||||
return jvPathState;
|
||||
}
|
||||
|
||||
TER RippleCalc::calcNodeFwd(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality)
|
||||
TER RippleCalc::calcNodeFwd(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality)
|
||||
{
|
||||
const PaymentNode& pnCur = pspCur->vpnNodes[uIndex];
|
||||
const bool bCurAccount = isSetBit(pnCur.uFlags, STPathElement::typeAccount);
|
||||
@@ -1743,7 +1743,7 @@ TER RippleCalc::calcNodeFwd(const unsigned int uIndex, const PathState::pointer&
|
||||
// --> [all]saWanted.mCurrency
|
||||
// --> [all]saAccount
|
||||
// <-> [0]saWanted.mAmount : --> limit, <-- actual
|
||||
TER RippleCalc::calcNodeRev(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality)
|
||||
TER RippleCalc::calcNodeRev(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality)
|
||||
{
|
||||
PaymentNode& pnCur = pspCur->vpnNodes[uIndex];
|
||||
const bool bCurAccount = isSetBit(pnCur.uFlags, STPathElement::typeAccount);
|
||||
@@ -1785,7 +1785,7 @@ TER RippleCalc::calcNodeRev(const unsigned int uIndex, const PathState::pointer&
|
||||
// Calculate the next increment of a path.
|
||||
// The increment is what can satisfy a portion or all of the requested output at the best quality.
|
||||
// <-- pspCur->uQuality
|
||||
void RippleCalc::pathNext(const PathState::pointer& pspCur, const int iPaths, const LedgerEntrySet& lesCheckpoint, LedgerEntrySet& lesCurrent)
|
||||
void RippleCalc::pathNext(PathState::ref pspCur, const int iPaths, const LedgerEntrySet& lesCheckpoint, LedgerEntrySet& lesCurrent)
|
||||
{
|
||||
// The next state is what is available in preference order.
|
||||
// This is calculated when referenced accounts changed.
|
||||
|
||||
@@ -65,13 +65,14 @@ extern std::size_t hash_value(const aciSource& asValue);
|
||||
class PathState
|
||||
{
|
||||
protected:
|
||||
const Ledger::pointer& mLedger;
|
||||
Ledger::ref mLedger;
|
||||
|
||||
TER pushNode(const int iType, const uint160& uAccountID, const uint160& uCurrencyID, const uint160& uIssuerID);
|
||||
TER pushImply(const uint160& uAccountID, const uint160& uCurrencyID, const uint160& uIssuerID);
|
||||
|
||||
public:
|
||||
typedef boost::shared_ptr<PathState> pointer;
|
||||
typedef boost::shared_ptr<PathState> pointer;
|
||||
typedef const boost::shared_ptr<PathState>& ref;
|
||||
|
||||
TER terStatus;
|
||||
std::vector<PaymentNode> vpnNodes;
|
||||
@@ -123,7 +124,7 @@ public:
|
||||
return boost::make_shared<PathState>(iIndex, lesSource, spSourcePath, uReceiverID, uSenderID, saSend, saSendMax);
|
||||
}
|
||||
|
||||
static bool lessPriority(const PathState::pointer& lhs, const PathState::pointer& rhs);
|
||||
static bool lessPriority(PathState::ref lhs, PathState::ref rhs);
|
||||
};
|
||||
|
||||
class RippleCalc
|
||||
@@ -139,18 +140,18 @@ public:
|
||||
boost::unordered_set<uint256> musUnfundedFound; // Offers that were found unfunded.
|
||||
|
||||
PathState::pointer pathCreate(const STPath& spPath);
|
||||
void pathNext(const PathState::pointer& pspCur, const int iPaths, const LedgerEntrySet& lesCheckpoint, LedgerEntrySet& lesCurrent);
|
||||
TER calcNode(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality);
|
||||
TER calcNodeRev(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality);
|
||||
TER calcNodeFwd(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality);
|
||||
TER calcNodeOfferRev(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality);
|
||||
TER calcNodeOfferFwd(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality);
|
||||
TER calcNodeAccountRev(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality);
|
||||
TER calcNodeAccountFwd(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality);
|
||||
TER calcNodeAdvance(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality, const bool bReverse);
|
||||
void pathNext(PathState::ref pspCur, const int iPaths, const LedgerEntrySet& lesCheckpoint, LedgerEntrySet& lesCurrent);
|
||||
TER calcNode(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality);
|
||||
TER calcNodeRev(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality);
|
||||
TER calcNodeFwd(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality);
|
||||
TER calcNodeOfferRev(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality);
|
||||
TER calcNodeOfferFwd(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality);
|
||||
TER calcNodeAccountRev(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality);
|
||||
TER calcNodeAccountFwd(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality);
|
||||
TER calcNodeAdvance(const unsigned int uIndex, PathState::ref pspCur, const bool bMultiQuality, const bool bReverse);
|
||||
TER calcNodeDeliverRev(
|
||||
const unsigned int uIndex,
|
||||
const PathState::pointer& pspCur,
|
||||
PathState::ref pspCur,
|
||||
const bool bMultiQuality,
|
||||
const uint160& uOutAccountID,
|
||||
const STAmount& saOutReq,
|
||||
@@ -158,7 +159,7 @@ public:
|
||||
|
||||
TER calcNodeDeliverFwd(
|
||||
const unsigned int uIndex,
|
||||
const PathState::pointer& pspCur,
|
||||
PathState::ref pspCur,
|
||||
const bool bMultiQuality,
|
||||
const uint160& uInAccountID,
|
||||
const STAmount& saInFunds,
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
|
||||
SETUP_LOG();
|
||||
|
||||
RippleLines::RippleLines(const uint160& accountID, Ledger::pointer ledger)
|
||||
RippleLines::RippleLines(const uint160& accountID, Ledger::ref ledger)
|
||||
{
|
||||
fillLines(accountID,ledger);
|
||||
fillLines(accountID, ledger);
|
||||
}
|
||||
|
||||
void RippleLines::printRippleLines()
|
||||
@@ -25,7 +25,7 @@ RippleLines::RippleLines(const uint160& accountID )
|
||||
fillLines(accountID,theApp->getMasterLedger().getCurrentLedger());
|
||||
}
|
||||
|
||||
void RippleLines::fillLines(const uint160& accountID, Ledger::pointer ledger)
|
||||
void RippleLines::fillLines(const uint160& accountID, Ledger::ref ledger)
|
||||
{
|
||||
uint256 rootIndex = Ledger::getOwnerDirIndex(accountID);
|
||||
uint256 currentIndex = rootIndex;
|
||||
|
||||
@@ -9,12 +9,12 @@ It provides a vector so you to easily iterate through them
|
||||
class RippleLines
|
||||
{
|
||||
std::vector<RippleState::pointer> mLines;
|
||||
void fillLines(const uint160& accountID, Ledger::pointer ledger);
|
||||
void fillLines(const uint160& accountID, Ledger::ref ledger);
|
||||
public:
|
||||
|
||||
RippleLines(const uint160& accountID, Ledger::pointer ledger);
|
||||
RippleLines(const uint160& accountID, Ledger::ref ledger);
|
||||
RippleLines(const uint160& accountID ); // looks in the current ledger
|
||||
|
||||
std::vector<RippleState::pointer>& getLines(){ return(mLines); }
|
||||
std::vector<RippleState::pointer>& getLines() { return(mLines); }
|
||||
void printRippleLines();
|
||||
};
|
||||
|
||||
@@ -208,7 +208,7 @@ public:
|
||||
bool hasItem() const { return !!mItem; }
|
||||
SHAMapItem::ref peekItem() { return mItem; }
|
||||
SHAMapItem::pointer getItem() const;
|
||||
bool setItem(const SHAMapItem::pointer& i, TNType type);
|
||||
bool setItem(SHAMapItem::ref i, TNType type);
|
||||
const uint256& getTag() const { return mItem->getTag(); }
|
||||
const std::vector<unsigned char>& peekData() { return mItem->peekData(); }
|
||||
std::vector<unsigned char> getData() const { return mItem->getData(); }
|
||||
|
||||
@@ -185,7 +185,7 @@ SHAMapTreeNode::SHAMapTreeNode(const SHAMapTreeNode& node, uint32 seq) : SHAMapN
|
||||
memcpy(mHashes, node.mHashes, sizeof(mHashes));
|
||||
}
|
||||
|
||||
SHAMapTreeNode::SHAMapTreeNode(const SHAMapNode& node, const SHAMapItem::pointer& item, TNType type, uint32 seq) :
|
||||
SHAMapTreeNode::SHAMapTreeNode(const SHAMapNode& node, SHAMapItem::ref item, TNType type, uint32 seq) :
|
||||
SHAMapNode(node), mItem(item), mSeq(seq), mType(type), mFullBelow(true)
|
||||
{
|
||||
assert(item->peekData().size() >= 12);
|
||||
@@ -465,7 +465,7 @@ void SHAMapTreeNode::addRaw(Serializer& s, SHANodeFormat format)
|
||||
assert(false);
|
||||
}
|
||||
|
||||
bool SHAMapTreeNode::setItem(const SHAMapItem::pointer& i, TNType type)
|
||||
bool SHAMapTreeNode::setItem(SHAMapItem::ref i, TNType type)
|
||||
{
|
||||
uint256 hash = getNodeHash();
|
||||
mType = type;
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
class SerializedTransaction : public STObject
|
||||
{
|
||||
public:
|
||||
typedef boost::shared_ptr<SerializedTransaction> pointer;
|
||||
typedef boost::shared_ptr<SerializedTransaction> pointer;
|
||||
typedef const boost::shared_ptr<SerializedTransaction>& ref;
|
||||
|
||||
protected:
|
||||
TransactionType mType;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "SerializedTransaction.h"
|
||||
#include "Log.h"
|
||||
|
||||
Transaction::Transaction(const SerializedTransaction::pointer& sit, bool bValidate)
|
||||
Transaction::Transaction(SerializedTransaction::ref sit, bool bValidate)
|
||||
: mInLedger(0), mStatus(INVALID), mResult(temUNCERTAIN), mTransaction(sit)
|
||||
{
|
||||
try
|
||||
@@ -709,8 +709,8 @@ bool Transaction::convertToTransactions(uint32 firstLedgerSeq, uint32 secondLedg
|
||||
for(it = inMap.begin(); it != inMap.end(); ++it)
|
||||
{
|
||||
const uint256& id = it->first;
|
||||
const SHAMapItem::pointer& first = it->second.first;
|
||||
const SHAMapItem::pointer& second = it->second.second;
|
||||
SHAMapItem::ref first = it->second.first;
|
||||
SHAMapItem::ref second = it->second.second;
|
||||
|
||||
Transaction::pointer firstTrans, secondTrans;
|
||||
if (!!first)
|
||||
|
||||
@@ -129,7 +129,7 @@ private:
|
||||
const std::vector<unsigned char>& vucSignature);
|
||||
|
||||
public:
|
||||
Transaction(const SerializedTransaction::pointer& st, bool bValidate);
|
||||
Transaction(SerializedTransaction::ref st, bool bValidate);
|
||||
|
||||
static Transaction::pointer sharedTransaction(const std::vector<unsigned char>&vucTransaction, bool bValidate);
|
||||
static Transaction::pointer transactionFromSQL(Database* db, bool bValidate);
|
||||
|
||||
@@ -31,7 +31,7 @@ Transaction::pointer TransactionMaster::fetch(const uint256& txnID, bool checkDi
|
||||
return txn;
|
||||
}
|
||||
|
||||
SerializedTransaction::pointer TransactionMaster::fetch(const SHAMapItem::pointer& item, bool checkDisk, uint32 uCommitLedger)
|
||||
SerializedTransaction::pointer TransactionMaster::fetch(SHAMapItem::ref item, bool checkDisk, uint32 uCommitLedger)
|
||||
{
|
||||
SerializedTransaction::pointer txn;
|
||||
Transaction::pointer iTx = theApp->getMasterTransaction().fetch(item->getTag(), false);
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
TransactionMaster();
|
||||
|
||||
Transaction::pointer fetch(const uint256&, bool checkDisk);
|
||||
SerializedTransaction::pointer fetch(const SHAMapItem::pointer& item, bool checkDisk, uint32 uCommitLedger);
|
||||
SerializedTransaction::pointer fetch(SHAMapItem::ref item, bool checkDisk, uint32 uCommitLedger);
|
||||
|
||||
// return value: true = we had the transaction already
|
||||
bool canonicalize(Transaction::pointer& txn, bool maybeNew);
|
||||
|
||||
Reference in New Issue
Block a user