mirror of
https://github.com/XRPLF/rippled.git
synced 2026-10-04 02:38:02 +00:00
Clean up pre C++1 idioms:
* Use auto for in some loops * Fix shadowing iterator declaration * Rename NUMBER to ARRAYSIZE. * Use placeholders instead of macros * Replace macro BIND_TYPE with std::bind * Replace BOOST_FOREACH with range-for
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -61,7 +61,7 @@ const char* TxnDBInit[] =
|
||||
"END TRANSACTION;"
|
||||
};
|
||||
|
||||
int TxnDBCount = NUMBER (TxnDBInit);
|
||||
int TxnDBCount = std::extent<decltype(TxnDBInit)>::value;
|
||||
|
||||
// Ledger database holds ledgers and ledger confirmations
|
||||
const char* LedgerDBInit[] =
|
||||
@@ -100,7 +100,7 @@ const char* LedgerDBInit[] =
|
||||
"END TRANSACTION;"
|
||||
};
|
||||
|
||||
int LedgerDBCount = NUMBER (LedgerDBInit);
|
||||
int LedgerDBCount = std::extent<decltype(LedgerDBInit)>::value;
|
||||
|
||||
// RPC database holds persistent data for RPC clients.
|
||||
const char* RpcDBInit[] =
|
||||
@@ -113,7 +113,7 @@ const char* RpcDBInit[] =
|
||||
);",
|
||||
};
|
||||
|
||||
int RpcDBCount = NUMBER (RpcDBInit);
|
||||
int RpcDBCount = std::extent<decltype(RpcDBInit)>::value;
|
||||
|
||||
// NodeIdentity database holds local accounts and trusted nodes
|
||||
// VFALCO NOTE but its a table not a database, so...?
|
||||
@@ -273,13 +273,13 @@ const char* WalletDBInit[] =
|
||||
"END TRANSACTION;"
|
||||
};
|
||||
|
||||
int WalletDBCount = NUMBER (WalletDBInit);
|
||||
int WalletDBCount = std::extent<decltype(WalletDBInit)>::value;
|
||||
|
||||
// Hash node database holds nodes indexed by hash
|
||||
// VFALCO TODO Remove this since it looks unused
|
||||
/*
|
||||
|
||||
int HashNodeDBCount = NUMBER (HashNodeDBInit);
|
||||
int HashNodeDBCount = std::extent<decltype(HashNodeDBInit)>::value;
|
||||
*/
|
||||
|
||||
// Net node database holds nodes seen on the network
|
||||
@@ -295,7 +295,7 @@ const char* NetNodeDBInit[] =
|
||||
);"
|
||||
};
|
||||
|
||||
int NetNodeDBCount = NUMBER (NetNodeDBInit);
|
||||
int NetNodeDBCount = std::extent<decltype(NetNodeDBInit)>::value;
|
||||
*/
|
||||
|
||||
// This appears to be unused
|
||||
@@ -331,7 +331,7 @@ const char* PathFindDBInit[] =
|
||||
"CREATE INDEX ExTo ON Exchanges(To, Currency, Use);",
|
||||
};
|
||||
|
||||
int PathFindDBCount = NUMBER (PathFindDBInit);
|
||||
int PathFindDBCount = std::extent<decltype(PathFindDBInit)>::value;
|
||||
*/
|
||||
|
||||
} // ripple
|
||||
|
||||
@@ -319,7 +319,7 @@ void SqliteDatabase::doHook (const char* db, int pages)
|
||||
|
||||
if (mWalQ)
|
||||
{
|
||||
mWalQ->addJob (jtWAL, std::string ("WAL:") + mHost, BIND_TYPE (&SqliteDatabase::runWal, this));
|
||||
mWalQ->addJob (jtWAL, std::string ("WAL:") + mHost, std::bind (&SqliteDatabase::runWal, this));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -259,8 +259,8 @@ void InboundLedger::onTimer (bool wasProgress, ScopedLockType&)
|
||||
mByHash = true;
|
||||
|
||||
std::size_t pc = getPeerCount ();
|
||||
WriteLog (lsDEBUG, InboundLedger) <<
|
||||
"No progress(" << pc <<
|
||||
WriteLog (lsDEBUG, InboundLedger) <<
|
||||
"No progress(" << pc <<
|
||||
") for ledger " << mHash;
|
||||
|
||||
trigger (Peer::ptr ());
|
||||
@@ -278,7 +278,7 @@ void InboundLedger::addPeers ()
|
||||
|
||||
if (vSize == 0)
|
||||
{
|
||||
WriteLog (lsERROR, InboundLedger) <<
|
||||
WriteLog (lsERROR, InboundLedger) <<
|
||||
"No peers to add for ledger acquisition";
|
||||
return;
|
||||
}
|
||||
@@ -329,7 +329,7 @@ void InboundLedger::addPeers ()
|
||||
}
|
||||
else if (mSeq != 0)
|
||||
{
|
||||
if (m_journal.debug) m_journal.debug <<
|
||||
if (m_journal.debug) m_journal.debug <<
|
||||
"Found " << found << " peer(s) with ledger " << mSeq;
|
||||
}
|
||||
else
|
||||
@@ -391,7 +391,8 @@ void InboundLedger::done ()
|
||||
|
||||
// We hold the PeerSet lock, so must dispatch
|
||||
getApp().getJobQueue ().addJob (jtLEDGER_DATA, "triggers",
|
||||
BIND_TYPE (LADispatch, P_1, shared_from_this (), triggers));
|
||||
std::bind (LADispatch, std::placeholders::_1, shared_from_this (),
|
||||
triggers));
|
||||
}
|
||||
|
||||
bool InboundLedger::addOnComplete (
|
||||
@@ -1252,10 +1253,10 @@ Json::Value InboundLedger::getJson (int)
|
||||
if (mHaveBase && !mHaveState)
|
||||
{
|
||||
Json::Value hv (Json::arrayValue);
|
||||
|
||||
|
||||
// VFALCO Why 16?
|
||||
auto v = mLedger->getNeededAccountStateHashes (16, nullptr);
|
||||
|
||||
|
||||
for (auto const& h : v)
|
||||
{
|
||||
hv.append (to_string (h));
|
||||
|
||||
@@ -25,7 +25,7 @@ class InboundLedgersImp
|
||||
, public beast::LeakChecked <InboundLedgers>
|
||||
{
|
||||
public:
|
||||
typedef std::pair<uint256, InboundLedger::pointer> u256_acq_pair;
|
||||
typedef std::pair<uint256, InboundLedger::pointer> u256_acq_pair;
|
||||
// How long before we try again to acquire the same ledger
|
||||
static const int kReacquireIntervalSeconds = 300;
|
||||
|
||||
@@ -171,7 +171,7 @@ public:
|
||||
if (packet.type () == protocol::liAS_NODE)
|
||||
{
|
||||
getApp().getJobQueue().addJob(jtLEDGER_DATA, "gotStaleData",
|
||||
BIND_TYPE(&InboundLedgers::gotStaleData, this, packet_ptr));
|
||||
std::bind(&InboundLedgers::gotStaleData, this, packet_ptr));
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -180,7 +180,8 @@ public:
|
||||
// Stash the data for later processing and see if we need to dispatch
|
||||
if (ledger->gotData(boost::weak_ptr<Peer>(peer), packet_ptr))
|
||||
getApp().getJobQueue().addJob (jtLEDGER_DATA, "processLedgerData",
|
||||
BIND_TYPE (&InboundLedgers::doLedgerData, this, P_1, hash));
|
||||
std::bind (&InboundLedgers::doLedgerData, this,
|
||||
std::placeholders::_1, hash));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -624,7 +624,7 @@ bool Ledger::saveValidatedLedger (bool current)
|
||||
db->executeSQL (boost::str (deleteTrans1 % mLedgerSeq));
|
||||
db->executeSQL (boost::str (deleteTrans2 % mLedgerSeq));
|
||||
|
||||
BOOST_FOREACH (const AcceptedLedger::value_type & vt, aLedger->getMap ())
|
||||
for (auto const& vt : aLedger->getMap ())
|
||||
{
|
||||
uint256 txID = vt.second->getTransactionID ();
|
||||
getApp().getMasterTransaction ().inLedger (txID, mLedgerSeq);
|
||||
@@ -676,8 +676,8 @@ bool Ledger::saveValidatedLedger (bool current)
|
||||
|
||||
getApp().getLedgerDB ()->getDB ()->executeSQL (boost::str (addLedger %
|
||||
to_string (getHash ()) % mLedgerSeq % to_string (mParentHash) %
|
||||
beast::lexicalCastThrow <std::string> (mTotCoins) % mCloseTime %
|
||||
mParentCloseTime % mCloseResolution % mCloseFlags %
|
||||
beast::lexicalCastThrow <std::string> (mTotCoins) % mCloseTime %
|
||||
mParentCloseTime % mCloseResolution % mCloseFlags %
|
||||
to_string (mAccountHash) % to_string (mTransHash)));
|
||||
}
|
||||
|
||||
@@ -1107,9 +1107,11 @@ Json::Value Ledger::getJson (int options)
|
||||
{
|
||||
Json::Value& state = (ledger[jss::accountState] = Json::arrayValue);
|
||||
if (bFull || is_bit_set (options, LEDGER_JSON_EXPAND))
|
||||
visitStateItems(BIND_TYPE(stateItemFullAppender, std::ref(state), P_1));
|
||||
visitStateItems(std::bind(stateItemFullAppender, std::ref(state),
|
||||
std::placeholders::_1));
|
||||
else
|
||||
mAccountStateMap->visitLeaves(BIND_TYPE(stateItemTagAppender, std::ref(state), P_1));
|
||||
mAccountStateMap->visitLeaves(std::bind(stateItemTagAppender,
|
||||
std::ref(state), std::placeholders::_1));
|
||||
}
|
||||
|
||||
return ledger;
|
||||
@@ -1233,7 +1235,7 @@ void Ledger::visitAccountItems (const uint160& accountID, std::function<void (SL
|
||||
if (!ownerDir || (ownerDir->getType () != ltDIR_NODE))
|
||||
return;
|
||||
|
||||
BOOST_FOREACH (uint256 const & uNode, ownerDir->getFieldV256 (sfIndexes).peekValue ())
|
||||
for (auto const& uNode : ownerDir->getFieldV256 (sfIndexes).peekValue ())
|
||||
{
|
||||
func (getSLEi (uNode));
|
||||
}
|
||||
@@ -1243,7 +1245,7 @@ void Ledger::visitAccountItems (const uint160& accountID, std::function<void (SL
|
||||
if (!uNodeNext)
|
||||
return;
|
||||
|
||||
currentIndex = Ledger::getDirNodeIndex (rootIndex, uNodeNext);
|
||||
currentIndex = Ledger::getDirNodeIndex (rootIndex, uNodeNext);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1258,7 +1260,8 @@ void Ledger::visitStateItems (std::function<void (SLE::ref)> function)
|
||||
try
|
||||
{
|
||||
if (mAccountStateMap)
|
||||
mAccountStateMap->visitLeaves(BIND_TYPE(&visitHelper, std::ref(function), P_1));
|
||||
mAccountStateMap->visitLeaves(std::bind(&visitHelper,
|
||||
std::ref(function), std::placeholders::_1));
|
||||
}
|
||||
catch (SHAMapMissingNode&)
|
||||
{
|
||||
@@ -1919,12 +1922,14 @@ bool Ledger::pendSaveValidated (bool isSynchronous, bool isCurrent)
|
||||
else if (isCurrent)
|
||||
{
|
||||
getApp().getJobQueue ().addJob (jtPUBLEDGER, "Ledger::pendSave",
|
||||
BIND_TYPE (&Ledger::saveValidatedLedgerAsync, shared_from_this (), P_1, isCurrent));
|
||||
std::bind (&Ledger::saveValidatedLedgerAsync, shared_from_this (),
|
||||
std::placeholders::_1, isCurrent));
|
||||
}
|
||||
else
|
||||
{
|
||||
getApp().getJobQueue ().addJob (jtPUBOLDLEDGER, "Ledger::pendOldSave",
|
||||
BIND_TYPE (&Ledger::saveValidatedLedgerAsync, shared_from_this (), P_1, isCurrent));
|
||||
std::bind (&Ledger::saveValidatedLedgerAsync, shared_from_this (),
|
||||
std::placeholders::_1, isCurrent));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -71,7 +71,7 @@ void LedgerEntrySet::swapWith (LedgerEntrySet& e)
|
||||
// This is basically: copy-on-read.
|
||||
SLE::pointer LedgerEntrySet::getEntry (uint256 const& index, LedgerEntryAction& action)
|
||||
{
|
||||
std::map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find (index);
|
||||
auto it = mEntries.find (index);
|
||||
|
||||
if (it == mEntries.end ())
|
||||
{
|
||||
@@ -137,7 +137,7 @@ void LedgerEntrySet::entryCache (SLE::ref sle)
|
||||
{
|
||||
assert (mLedger);
|
||||
assert (sle->isMutable () || mImmutable); // Don't put an immutable SLE in a mutable LES
|
||||
std::map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find (sle->getIndex ());
|
||||
auto it = mEntries.find (sle->getIndex ());
|
||||
|
||||
if (it == mEntries.end ())
|
||||
{
|
||||
@@ -162,7 +162,7 @@ void LedgerEntrySet::entryCreate (SLE::ref sle)
|
||||
{
|
||||
assert (mLedger && !mImmutable);
|
||||
assert (sle->isMutable ());
|
||||
std::map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find (sle->getIndex ());
|
||||
auto it = mEntries.find (sle->getIndex ());
|
||||
|
||||
if (it == mEntries.end ())
|
||||
{
|
||||
@@ -200,7 +200,7 @@ void LedgerEntrySet::entryModify (SLE::ref sle)
|
||||
{
|
||||
assert (sle->isMutable () && !mImmutable);
|
||||
assert (mLedger);
|
||||
std::map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find (sle->getIndex ());
|
||||
auto it = mEntries.find (sle->getIndex ());
|
||||
|
||||
if (it == mEntries.end ())
|
||||
{
|
||||
@@ -236,7 +236,7 @@ void LedgerEntrySet::entryDelete (SLE::ref sle)
|
||||
{
|
||||
assert (sle->isMutable () && !mImmutable);
|
||||
assert (mLedger);
|
||||
std::map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find (sle->getIndex ());
|
||||
auto it = mEntries.find (sle->getIndex ());
|
||||
|
||||
if (it == mEntries.end ())
|
||||
{
|
||||
@@ -271,11 +271,9 @@ void LedgerEntrySet::entryDelete (SLE::ref sle)
|
||||
|
||||
bool LedgerEntrySet::hasChanges ()
|
||||
{
|
||||
typedef std::map<uint256, LedgerEntrySetEntry>::value_type u256_LES_pair;
|
||||
BOOST_FOREACH (u256_LES_pair & it, mEntries)
|
||||
|
||||
if (it.second.mAction != taaCACHED)
|
||||
return true;
|
||||
for (auto const& it : mEntries)
|
||||
if (it.second.mAction != taaCACHED)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -360,7 +358,7 @@ Json::Value LedgerEntrySet::getJson (int) const
|
||||
SLE::pointer LedgerEntrySet::getForMod (uint256 const& node, Ledger::ref ledger,
|
||||
ripple::unordered_map<uint256, SLE::pointer>& newMods)
|
||||
{
|
||||
std::map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find (node);
|
||||
auto it = mEntries.find (node);
|
||||
|
||||
if (it != mEntries.end ())
|
||||
{
|
||||
@@ -382,7 +380,7 @@ SLE::pointer LedgerEntrySet::getForMod (uint256 const& node, Ledger::ref ledger,
|
||||
return it->second.mEntry;
|
||||
}
|
||||
|
||||
ripple::unordered_map<uint256, SLE::pointer>::iterator me = newMods.find (node);
|
||||
auto me (newMods.find (node));
|
||||
|
||||
if (me != newMods.end ())
|
||||
{
|
||||
@@ -467,8 +465,7 @@ void LedgerEntrySet::calcRawMeta (Serializer& s, TER result, std::uint32_t index
|
||||
// Entries modified only as a result of building the transaction metadata
|
||||
ripple::unordered_map<uint256, SLE::pointer> newMod;
|
||||
|
||||
typedef std::map<uint256, LedgerEntrySetEntry>::value_type u256_LES_pair;
|
||||
BOOST_FOREACH (u256_LES_pair & it, mEntries)
|
||||
for (auto& it : mEntries)
|
||||
{
|
||||
SField::ptr type = &sfGeneric;
|
||||
|
||||
@@ -508,8 +505,9 @@ void LedgerEntrySet::calcRawMeta (Serializer& s, TER result, std::uint32_t index
|
||||
if ((type == &sfModifiedNode) && (*curNode == *origNode))
|
||||
continue;
|
||||
|
||||
std::uint16_t nodeType = curNode ? curNode->getFieldU16 (sfLedgerEntryType)
|
||||
: origNode->getFieldU16 (sfLedgerEntryType);
|
||||
std::uint16_t nodeType = curNode
|
||||
? curNode->getFieldU16 (sfLedgerEntryType)
|
||||
: origNode->getFieldU16 (sfLedgerEntryType);
|
||||
|
||||
mSet.setAffectedNode (it.first, *type, nodeType);
|
||||
|
||||
@@ -519,7 +517,7 @@ void LedgerEntrySet::calcRawMeta (Serializer& s, TER result, std::uint32_t index
|
||||
threadOwners (origNode, mLedger, newMod); // thread transaction to owners
|
||||
|
||||
STObject prevs (sfPreviousFields);
|
||||
BOOST_FOREACH (const SerializedType & obj, *origNode)
|
||||
for (auto const& obj : *origNode)
|
||||
{
|
||||
// go through the original node for modified fields saved on modification
|
||||
if (obj.getFName ().shouldMeta (SField::sMD_ChangeOrig) && !curNode->hasMatchingEntry (obj))
|
||||
@@ -530,7 +528,7 @@ void LedgerEntrySet::calcRawMeta (Serializer& s, TER result, std::uint32_t index
|
||||
mSet.getAffectedNode (it.first).addObject (prevs);
|
||||
|
||||
STObject finals (sfFinalFields);
|
||||
BOOST_FOREACH (const SerializedType & obj, *curNode)
|
||||
for (auto const& obj : *curNode)
|
||||
{
|
||||
// go through the final node for final fields
|
||||
if (obj.getFName ().shouldMeta (SField::sMD_Always | SField::sMD_DeleteFinal))
|
||||
@@ -548,7 +546,7 @@ void LedgerEntrySet::calcRawMeta (Serializer& s, TER result, std::uint32_t index
|
||||
threadTx (curNode, mLedger, newMod);
|
||||
|
||||
STObject prevs (sfPreviousFields);
|
||||
BOOST_FOREACH (const SerializedType & obj, *origNode)
|
||||
for (auto const& obj : *origNode)
|
||||
{
|
||||
// search the original node for values saved on modify
|
||||
if (obj.getFName ().shouldMeta (SField::sMD_ChangeOrig) && !curNode->hasMatchingEntry (obj))
|
||||
@@ -559,7 +557,7 @@ void LedgerEntrySet::calcRawMeta (Serializer& s, TER result, std::uint32_t index
|
||||
mSet.getAffectedNode (it.first).addObject (prevs);
|
||||
|
||||
STObject finals (sfFinalFields);
|
||||
BOOST_FOREACH (const SerializedType & obj, *curNode)
|
||||
for (auto const& obj : *curNode)
|
||||
{
|
||||
// search the final node for values saved always
|
||||
if (obj.getFName ().shouldMeta (SField::sMD_Always | SField::sMD_ChangeNew))
|
||||
@@ -578,7 +576,7 @@ void LedgerEntrySet::calcRawMeta (Serializer& s, TER result, std::uint32_t index
|
||||
threadTx (curNode, mLedger, newMod);
|
||||
|
||||
STObject news (sfNewFields);
|
||||
BOOST_FOREACH (const SerializedType & obj, *curNode)
|
||||
for (auto const& obj : *curNode)
|
||||
{
|
||||
// save non-default values
|
||||
if (!obj.isDefault () && obj.getFName ().shouldMeta (SField::sMD_Create | SField::sMD_Always))
|
||||
@@ -592,8 +590,7 @@ void LedgerEntrySet::calcRawMeta (Serializer& s, TER result, std::uint32_t index
|
||||
}
|
||||
|
||||
// add any new modified nodes to the modification set
|
||||
typedef std::map<uint256, SLE::pointer>::value_type u256_sle_pair;
|
||||
BOOST_FOREACH (u256_sle_pair & it, newMod)
|
||||
for (auto& it : newMod)
|
||||
entryModify (it.second);
|
||||
|
||||
mSet.addRaw (s, result, index);
|
||||
@@ -730,7 +727,7 @@ TER LedgerEntrySet::dirAdd (
|
||||
svIndexes.peekValue ().push_back (uLedgerIndex); // Append entry.
|
||||
sleNode->setFieldV256 (sfIndexes, svIndexes); // Save entry.
|
||||
|
||||
WriteLog (lsTRACE, LedgerEntrySet) <<
|
||||
WriteLog (lsTRACE, LedgerEntrySet) <<
|
||||
"dirAdd: creating: root: " << to_string (uRootIndex);
|
||||
WriteLog (lsTRACE, LedgerEntrySet) <<
|
||||
"dirAdd: appending: Entry: " << to_string (uLedgerIndex);
|
||||
@@ -777,11 +774,10 @@ TER LedgerEntrySet::dirDelete (
|
||||
}
|
||||
}
|
||||
|
||||
STVector256 svIndexes = sleNode->getFieldV256 (sfIndexes);
|
||||
std::vector<uint256>& vuiIndexes = svIndexes.peekValue ();
|
||||
std::vector<uint256>::iterator it;
|
||||
STVector256 svIndexes = sleNode->getFieldV256 (sfIndexes);
|
||||
std::vector<uint256>& vuiIndexes = svIndexes.peekValue ();
|
||||
|
||||
it = std::find (vuiIndexes.begin (), vuiIndexes.end (), uLedgerIndex);
|
||||
auto it = std::find (vuiIndexes.begin (), vuiIndexes.end (), uLedgerIndex);
|
||||
|
||||
if (vuiIndexes.end () == it)
|
||||
{
|
||||
@@ -797,7 +793,8 @@ TER LedgerEntrySet::dirDelete (
|
||||
{
|
||||
// Go the extra mile. Even if entry not in node, try the next node.
|
||||
|
||||
return dirDelete (bKeepRoot, uNodeDir + 1, uRootIndex, uLedgerIndex, bStable, true);
|
||||
return dirDelete (bKeepRoot, uNodeDir + 1, uRootIndex, uLedgerIndex,
|
||||
bStable, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1123,7 +1120,7 @@ STAmount LedgerEntrySet::rippleOwed (const uint160& uToAccountID, const uint160&
|
||||
saBalance.clear (uCurrencyID, uToAccountID);
|
||||
|
||||
WriteLog (lsDEBUG, LedgerEntrySet) << "rippleOwed:" <<
|
||||
" No credit line between " <<
|
||||
" No credit line between " <<
|
||||
RippleAddress::createHumanAccountID (uFromAccountID) <<
|
||||
" and " << RippleAddress::createHumanAccountID (uToAccountID) <<
|
||||
" for " << STAmount::createHumanCurrency (uCurrencyID);
|
||||
@@ -1167,7 +1164,7 @@ std::uint32_t LedgerEntrySet::rippleTransferRate (const uint160& uIssuerID)
|
||||
SLE::pointer sleAccount (entryCache (
|
||||
ltACCOUNT_ROOT, Ledger::getAccountRootIndex (uIssuerID)));
|
||||
|
||||
std::uint32_t uQuality =
|
||||
std::uint32_t uQuality =
|
||||
sleAccount && sleAccount->isFieldPresent (sfTransferRate)
|
||||
? sleAccount->getFieldU32 (sfTransferRate)
|
||||
: QUALITY_ONE;
|
||||
@@ -1208,7 +1205,7 @@ LedgerEntrySet::rippleQualityIn (const uint160& uToAccountID,
|
||||
}
|
||||
else
|
||||
{
|
||||
sleRippleState = entryCache (ltRIPPLE_STATE,
|
||||
sleRippleState = entryCache (ltRIPPLE_STATE,
|
||||
Ledger::getRippleStateIndex (uToAccountID, uFromAccountID, uCurrencyID));
|
||||
|
||||
if (sleRippleState)
|
||||
@@ -1360,11 +1357,11 @@ STAmount LedgerEntrySet::rippleTransferFee (
|
||||
{
|
||||
// NIKB use STAmount::saFromRate
|
||||
STAmount saTransitRate (
|
||||
CURRENCY_ONE, ACCOUNT_ONE,
|
||||
CURRENCY_ONE, ACCOUNT_ONE,
|
||||
static_cast<std::uint64_t> (uTransitRate), -9);
|
||||
|
||||
STAmount saTransferTotal = STAmount::multiply (
|
||||
saAmount, saTransitRate,
|
||||
saAmount, saTransitRate,
|
||||
saAmount.getCurrency (), saAmount.getIssuer ());
|
||||
STAmount saTransferFee = saTransferTotal - saAmount;
|
||||
|
||||
@@ -1403,7 +1400,9 @@ TER LedgerEntrySet::trustCreate (
|
||||
uLowNode,
|
||||
Ledger::getOwnerDirIndex (uLowAccountID),
|
||||
sleRippleState->getIndex (),
|
||||
BIND_TYPE (&Ledger::ownerDirDescriber, P_1, P_2, uLowAccountID));
|
||||
std::bind (&Ledger::ownerDirDescriber,
|
||||
std::placeholders::_1, std::placeholders::_2,
|
||||
uLowAccountID));
|
||||
|
||||
if (tesSUCCESS == terResult)
|
||||
{
|
||||
@@ -1411,7 +1410,9 @@ TER LedgerEntrySet::trustCreate (
|
||||
uHighNode,
|
||||
Ledger::getOwnerDirIndex (uHighAccountID),
|
||||
sleRippleState->getIndex (),
|
||||
BIND_TYPE (&Ledger::ownerDirDescriber, P_1, P_2, uHighAccountID));
|
||||
std::bind (&Ledger::ownerDirDescriber,
|
||||
std::placeholders::_1, std::placeholders::_2,
|
||||
uHighAccountID));
|
||||
}
|
||||
|
||||
if (tesSUCCESS == terResult)
|
||||
@@ -1534,7 +1535,7 @@ TER LedgerEntrySet::rippleCredit (const uint160& uSenderID, const uint160& uRece
|
||||
saBalance -= saAmount;
|
||||
|
||||
WriteLog (lsTRACE, LedgerEntrySet) << "rippleCredit: " <<
|
||||
RippleAddress::createHumanAccountID (uSenderID) <<
|
||||
RippleAddress::createHumanAccountID (uSenderID) <<
|
||||
" -> " << RippleAddress::createHumanAccountID (uReceiverID) <<
|
||||
" : before=" << saBefore.getFullText () <<
|
||||
" amount=" << saAmount.getFullText () <<
|
||||
@@ -1718,4 +1719,3 @@ TER LedgerEntrySet::accountSend (const uint160& uSenderID, const uint160& uRecei
|
||||
}
|
||||
|
||||
} // ripple
|
||||
|
||||
|
||||
@@ -400,7 +400,7 @@ public:
|
||||
|
||||
// Returns Ledgers we have all the nodes for and are indexed
|
||||
bool getValidatedRange (std::uint32_t& minVal, std::uint32_t& maxVal)
|
||||
{
|
||||
{
|
||||
maxVal = mPubLedgerSeq.load();
|
||||
|
||||
if (!maxVal)
|
||||
@@ -432,7 +432,7 @@ public:
|
||||
++minVal;
|
||||
|
||||
// Best effort for remaining exclusions
|
||||
BOOST_FOREACH(std::uint32_t v, sPendingSaves)
|
||||
for(auto v : sPendingSaves)
|
||||
{
|
||||
if ((v >= minVal) && (v <= maxVal))
|
||||
{
|
||||
@@ -484,7 +484,7 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
std::map< std::uint32_t, std::pair<uint256, uint256> >::iterator it = ledgerHashes.find (seq);
|
||||
auto it (ledgerHashes.find (seq));
|
||||
|
||||
if (it == ledgerHashes.end ())
|
||||
{
|
||||
@@ -496,7 +496,9 @@ public:
|
||||
mCompleteLedgers.setRange (minHas, maxHas);
|
||||
}
|
||||
maxHas = minHas;
|
||||
ledgerHashes = Ledger::getHashesByIndex ((seq < 500) ? 0 : (seq - 499), seq);
|
||||
ledgerHashes = Ledger::getHashesByIndex ((seq < 500)
|
||||
? 0
|
||||
: (seq - 499), seq);
|
||||
it = ledgerHashes.find (seq);
|
||||
|
||||
if (it == ledgerHashes.end ())
|
||||
@@ -528,7 +530,7 @@ public:
|
||||
int count = 0;
|
||||
|
||||
Overlay::PeerSequence peerList = getApp().overlay ().getActivePeers ();
|
||||
BOOST_FOREACH (const Peer::ptr & peer, peerList)
|
||||
for (auto const& peer : peerList)
|
||||
{
|
||||
if (peer->hasRange (nextLedger->getLedgerSeq() - 1, nextLedger->getLedgerSeq()))
|
||||
{
|
||||
@@ -565,13 +567,14 @@ public:
|
||||
try
|
||||
{
|
||||
hash = ledger->getLedgerHash (lSeq);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
WriteLog (lsWARNING, LedgerMaster) << "fixMismatch encounters partial ledger";
|
||||
clearLedger(lSeq);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
WriteLog (lsWARNING, LedgerMaster) <<
|
||||
"fixMismatch encounters partial ledger";
|
||||
clearLedger(lSeq);
|
||||
return;
|
||||
}
|
||||
|
||||
if (hash.isNonZero ())
|
||||
{
|
||||
@@ -581,8 +584,9 @@ public:
|
||||
if (otherLedger && (otherLedger->getHash () == hash))
|
||||
{
|
||||
// we closed the seam
|
||||
CondLog (invalidate != 0, lsWARNING, LedgerMaster) << "Match at " << lSeq << ", " <<
|
||||
invalidate << " prior ledgers invalidated";
|
||||
CondLog (invalidate != 0, lsWARNING, LedgerMaster) <<
|
||||
"Match at " << lSeq << ", " << invalidate <<
|
||||
" prior ledgers invalidated";
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -592,7 +596,8 @@ public:
|
||||
}
|
||||
|
||||
// all prior ledgers invalidated
|
||||
CondLog (invalidate != 0, lsWARNING, LedgerMaster) << "All " << invalidate << " prior ledgers invalidated";
|
||||
CondLog (invalidate != 0, lsWARNING, LedgerMaster) << "All " <<
|
||||
invalidate << " prior ledgers invalidated";
|
||||
}
|
||||
|
||||
void setFullLedger (Ledger::pointer ledger, bool isSynchronous, bool isCurrent)
|
||||
@@ -664,9 +669,9 @@ public:
|
||||
return;
|
||||
|
||||
// Ledger could match the ledger we're already building
|
||||
if (seq == mBuildingLedgerSeq)
|
||||
return;
|
||||
}
|
||||
if (seq == mBuildingLedgerSeq)
|
||||
return;
|
||||
}
|
||||
|
||||
Ledger::pointer ledger = mLedgerHistory.getLedgerByHash (hash);
|
||||
|
||||
@@ -681,7 +686,7 @@ public:
|
||||
ledger = l->getLedger();
|
||||
else
|
||||
{
|
||||
WriteLog (lsDEBUG, LedgerMaster) <<
|
||||
WriteLog (lsDEBUG, LedgerMaster) <<
|
||||
"checkAccept triggers acquire " << to_string (hash);
|
||||
}
|
||||
}
|
||||
@@ -765,7 +770,7 @@ public:
|
||||
/** Report that the consensus process built a particular ledger */
|
||||
void consensusBuilt (Ledger::ref ledger) override
|
||||
{
|
||||
|
||||
|
||||
// Because we just built a ledger, we are no longer building one
|
||||
setBuildingLedger (0);
|
||||
|
||||
@@ -939,8 +944,9 @@ public:
|
||||
{ // Previous ledger is in DB
|
||||
ScopedLockType sl(m_mutex);
|
||||
mFillInProgress = ledger->getLedgerSeq();
|
||||
getApp().getJobQueue().addJob(jtADVANCE, "tryFill", BIND_TYPE (
|
||||
&LedgerMasterImp::tryFill, this, P_1, ledger));
|
||||
getApp().getJobQueue().addJob(jtADVANCE, "tryFill", std::bind (
|
||||
&LedgerMasterImp::tryFill, this,
|
||||
std::placeholders::_1, ledger));
|
||||
}
|
||||
progress = true;
|
||||
}
|
||||
@@ -984,12 +990,15 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLog (lsTRACE, LedgerMaster) << "tryAdvance found " << pubLedgers.size() << " ledgers to publish";
|
||||
BOOST_FOREACH(Ledger::ref ledger, pubLedgers)
|
||||
WriteLog (lsTRACE, LedgerMaster) <<
|
||||
"tryAdvance found " << pubLedgers.size() <<
|
||||
" ledgers to publish";
|
||||
for(auto ledger : pubLedgers)
|
||||
{
|
||||
{
|
||||
ScopedUnlockType sul (m_mutex);
|
||||
WriteLog(lsDEBUG, LedgerMaster) << "tryAdvance publishing seq " << ledger->getLedgerSeq();
|
||||
WriteLog(lsDEBUG, LedgerMaster) <<
|
||||
"tryAdvance publishing seq " << ledger->getLedgerSeq();
|
||||
|
||||
setFullLedger(ledger, true, true);
|
||||
getApp().getOPs().pubLedger(ledger);
|
||||
@@ -1116,20 +1125,20 @@ public:
|
||||
{
|
||||
mAdvanceThread = true;
|
||||
getApp().getJobQueue ().addJob (jtADVANCE, "advanceLedger",
|
||||
BIND_TYPE (&LedgerMasterImp::advanceThread, this));
|
||||
std::bind (&LedgerMasterImp::advanceThread, this));
|
||||
}
|
||||
}
|
||||
|
||||
// Return the hash of the valid ledger with a particular sequence, given a subsequent ledger known valid
|
||||
uint256 getLedgerHash(std::uint32_t desiredSeq, Ledger::ref knownGoodLedger)
|
||||
{
|
||||
{
|
||||
assert(desiredSeq < knownGoodLedger->getLedgerSeq());
|
||||
|
||||
uint256 hash = knownGoodLedger->getLedgerHash(desiredSeq);
|
||||
|
||||
// Not directly in the given ledger
|
||||
if (hash.isZero ())
|
||||
{
|
||||
{
|
||||
std::uint32_t seq = (desiredSeq + 255) % 256;
|
||||
assert(seq < desiredSeq);
|
||||
|
||||
@@ -1244,7 +1253,8 @@ public:
|
||||
{
|
||||
++mPathFindThread;
|
||||
getApp().getJobQueue().addJob (jtUPDATE_PF, name,
|
||||
BIND_TYPE (&LedgerMasterImp::updatePaths, this, P_1));
|
||||
std::bind (&LedgerMasterImp::updatePaths, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1346,7 +1356,7 @@ public:
|
||||
// See if the hash for the ledger we need is in the reference ledger
|
||||
ledgerHash = referenceLedger->getLedgerHash (index);
|
||||
if (ledgerHash.isZero())
|
||||
{
|
||||
{
|
||||
// No, Try to get another ledger that might have the hash we need
|
||||
// Compute the index and hash of a ledger that will have the hash we need
|
||||
LedgerIndex refIndex = (index + 255) & (~255);
|
||||
|
||||
@@ -59,7 +59,7 @@ void OrderBookDB::setup (Ledger::ref ledger)
|
||||
update(ledger);
|
||||
else
|
||||
getApp().getJobQueue().addJob(jtUPDATE_PF, "OrderBookDB::update",
|
||||
BIND_TYPE(&OrderBookDB::update, this, ledger));
|
||||
std::bind(&OrderBookDB::update, this, ledger));
|
||||
}
|
||||
|
||||
static void updateHelper (SLE::ref entry,
|
||||
@@ -108,7 +108,8 @@ void OrderBookDB::update (Ledger::pointer ledger)
|
||||
|
||||
try
|
||||
{
|
||||
ledger->visitStateItems(BIND_TYPE(&updateHelper, P_1, boost::ref(seen), boost::ref(destMap),
|
||||
ledger->visitStateItems(std::bind(&updateHelper, std::placeholders::_1,
|
||||
boost::ref(seen), boost::ref(destMap),
|
||||
boost::ref(sourceMap), boost::ref(XRPBooks), boost::ref(books)));
|
||||
}
|
||||
catch (const SHAMapMissingNode&)
|
||||
@@ -138,7 +139,7 @@ void OrderBookDB::addOrderBook(const uint160& ci, const uint160& co,
|
||||
|
||||
if (toXRP)
|
||||
{ // We don't want to search through all the to-XRP or from-XRP order books!
|
||||
BOOST_FOREACH(OrderBook::ref ob, mSourceMap[RippleAssetRef(ci, ii)])
|
||||
for (auto ob : mSourceMap[RippleAssetRef(ci, ii)])
|
||||
{
|
||||
if (ob->getCurrencyOut().isZero ()) // also to XRP
|
||||
return;
|
||||
@@ -146,7 +147,7 @@ void OrderBookDB::addOrderBook(const uint160& ci, const uint160& co,
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_FOREACH(OrderBook::ref ob, mDestMap[RippleAssetRef(co, io)])
|
||||
for (auto ob : mDestMap[RippleAssetRef(co, io)])
|
||||
{
|
||||
if ((ob->getCurrencyIn() == ci) && (ob->getIssuerIn() == ii))
|
||||
return;
|
||||
@@ -168,8 +169,7 @@ void OrderBookDB::getBooksByTakerPays (RippleIssuer const& issuerID, RippleCurre
|
||||
std::vector<OrderBook::pointer>& bookRet)
|
||||
{
|
||||
ScopedLockType sl (mLock);
|
||||
ripple::unordered_map< RippleAsset, std::vector<OrderBook::pointer> >::const_iterator
|
||||
it = mSourceMap.find (RippleAssetRef (currencyID, issuerID));
|
||||
auto it = mSourceMap.find (RippleAssetRef (currencyID, issuerID));
|
||||
|
||||
if (it != mSourceMap.end ())
|
||||
bookRet = it->second;
|
||||
@@ -189,8 +189,7 @@ void OrderBookDB::getBooksByTakerGets (RippleIssuer const& issuerID, RippleCurre
|
||||
std::vector<OrderBook::pointer>& bookRet)
|
||||
{
|
||||
ScopedLockType sl (mLock);
|
||||
ripple::unordered_map< RippleAsset, std::vector<OrderBook::pointer> >::const_iterator
|
||||
it = mDestMap.find (RippleAssetRef (currencyID, issuerID));
|
||||
auto it = mDestMap.find (RippleAssetRef (currencyID, issuerID));
|
||||
|
||||
if (it != mDestMap.end ())
|
||||
bookRet = it->second;
|
||||
@@ -243,7 +242,7 @@ void OrderBookDB::processTxn (Ledger::ref ledger, const AcceptedLedgerTx& alTx,
|
||||
{
|
||||
// check if this is an offer or an offer cancel or a payment that consumes an offer
|
||||
//check to see what the meta looks like
|
||||
BOOST_FOREACH (STObject & node, alTx.getMeta ()->getNodes ())
|
||||
for (auto& node : alTx.getMeta ()->getNodes ())
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -296,7 +295,7 @@ void OrderBookDB::processTxn (Ledger::ref ledger, const AcceptedLedgerTx& alTx,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
BookListeners::BookListeners ()
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "Tuning.h"
|
||||
|
||||
namespace ripple {
|
||||
|
||||
|
||||
// VFALCO TODO Clean this global up
|
||||
static bool volatile doShutdown = false;
|
||||
|
||||
@@ -331,7 +331,7 @@ public:
|
||||
, m_txQueue (TxQueue::New ())
|
||||
|
||||
, m_validators (add (Validators::Manager::New (
|
||||
*this,
|
||||
*this,
|
||||
getConfig ().getModuleDatabasePath (),
|
||||
LogPartition::getJournal <ValidatorsLog> ())))
|
||||
|
||||
@@ -732,7 +732,7 @@ public:
|
||||
// move the instantiation inside a conditional:
|
||||
//
|
||||
// if (!getConfig ().RUN_STANDALONE)
|
||||
m_peers = make_Overlay (m_mainIoPool, *m_resourceManager,
|
||||
m_peers = make_Overlay (m_mainIoPool, *m_resourceManager,
|
||||
*m_siteFiles, getConfig ().getModuleDatabasePath (),
|
||||
*m_resolver, m_mainIoPool, m_peerSSLContext->get ());
|
||||
// add to Stoppable
|
||||
@@ -954,7 +954,7 @@ public:
|
||||
// running the various logic threads like Validators, PeerFinder, etc.
|
||||
prepare ();
|
||||
start ();
|
||||
|
||||
|
||||
|
||||
{
|
||||
if (!getConfig ().RUN_STANDALONE)
|
||||
@@ -1043,7 +1043,8 @@ public:
|
||||
}
|
||||
|
||||
m_jobQueue->addJob(jtSWEEP, "sweep",
|
||||
BIND_TYPE(&ApplicationImp::doSweep, this, P_1));
|
||||
std::bind(&ApplicationImp::doSweep, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,8 +47,8 @@ void NodeStoreScheduler::scheduleTask (NodeStore::Task& task)
|
||||
m_jobQueue->addJob (
|
||||
jtWRITE,
|
||||
"NodeObject::store",
|
||||
BIND_TYPE (&NodeStoreScheduler::doTask,
|
||||
this, boost::ref(task), P_1));
|
||||
std::bind (&NodeStoreScheduler::doTask,
|
||||
this, boost::ref(task), std::placeholders::_1));
|
||||
}
|
||||
|
||||
void NodeStoreScheduler::doTask (NodeStore::Task& task, Job&)
|
||||
|
||||
@@ -533,12 +533,12 @@ void NetworkOPsImp::onDeadlineTimer (beast::DeadlineTimer& timer)
|
||||
if (timer == m_heartbeatTimer)
|
||||
{
|
||||
getApp().getJobQueue ().addJob (jtNETOP_TIMER, "NetOPs.heartbeat",
|
||||
BIND_TYPE (&NetworkOPsImp::processHeartbeatTimer, this));
|
||||
std::bind (&NetworkOPsImp::processHeartbeatTimer, this));
|
||||
}
|
||||
else if (timer == m_clusterTimer)
|
||||
{
|
||||
getApp().getJobQueue ().addJob (jtNETOP_CLUSTER, "NetOPs.cluster",
|
||||
BIND_TYPE (&NetworkOPsImp::processClusterTimer, this));
|
||||
std::bind (&NetworkOPsImp::processClusterTimer, this));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -916,7 +916,7 @@ void NetworkOPsImp::runTransactionQueue ()
|
||||
}
|
||||
|
||||
if (getApp().getTxQueue ().stopProcessing (txn))
|
||||
getApp().getIOService ().post (BIND_TYPE (&NetworkOPsImp::runTransactionQueue, this));
|
||||
getApp().getIOService ().post (std::bind (&NetworkOPsImp::runTransactionQueue, this));
|
||||
}
|
||||
|
||||
Transaction::pointer NetworkOPsImp::processTransactionCb (
|
||||
@@ -2436,7 +2436,7 @@ void NetworkOPsImp::reportFeeChange ()
|
||||
(getApp().getFeeTrack ().getLoadFactor () == mLastLoadFactor))
|
||||
return;
|
||||
|
||||
getApp().getJobQueue ().addJob (jtCLIENT, "reportFeeChange->pubServer", BIND_TYPE (&NetworkOPsImp::pubServer, this));
|
||||
getApp().getJobQueue ().addJob (jtCLIENT, "reportFeeChange->pubServer", std::bind (&NetworkOPsImp::pubServer, this));
|
||||
}
|
||||
|
||||
Json::Value NetworkOPsImp::transJson (const SerializedTransaction& stTxn, TER terResult, bool bValidated,
|
||||
@@ -2864,15 +2864,15 @@ void NetworkOPsImp::getBookPage (Ledger::pointer lpLedger, const uint160& uTaker
|
||||
const uint256 uBookEnd = Ledger::getQualityNext (uBookBase);
|
||||
uint256 uTipIndex = uBookBase;
|
||||
|
||||
if (m_journal.trace)
|
||||
if (m_journal.trace)
|
||||
{
|
||||
m_journal.trace << "getBookPage:" <<
|
||||
" uTakerPaysCurrencyID=" <<
|
||||
" uTakerPaysCurrencyID=" <<
|
||||
STAmount::createHumanCurrency (uTakerPaysCurrencyID) <<
|
||||
" uTakerPaysIssuerID=" <<
|
||||
RippleAddress::createHumanAccountID (uTakerPaysIssuerID);
|
||||
m_journal.trace << "getBookPage:" <<
|
||||
" uTakerGetsCurrencyID=" <<
|
||||
" uTakerGetsCurrencyID=" <<
|
||||
STAmount::createHumanCurrency (uTakerGetsCurrencyID) <<
|
||||
" uTakerGetsIssuerID=" <<
|
||||
RippleAddress::createHumanAccountID (uTakerGetsIssuerID);
|
||||
@@ -3016,7 +3016,7 @@ void NetworkOPsImp::getBookPage (Ledger::pointer lpLedger, const uint160& uTaker
|
||||
STAmount saOwnerPays = (QUALITY_ONE == uOfferRate)
|
||||
? saTakerGetsFunded
|
||||
: std::min (
|
||||
saOwnerFunds,
|
||||
saOwnerFunds,
|
||||
STAmount::multiply (
|
||||
saTakerGetsFunded,
|
||||
STAmount (CURRENCY_ONE, ACCOUNT_ONE, uOfferRate, -9)));
|
||||
@@ -3273,11 +3273,14 @@ void NetworkOPsImp::makeFetchPack (Job&, boost::weak_ptr<Peer> wPeer,
|
||||
|
||||
wantLedger->peekAccountStateMap ()->getFetchPack
|
||||
(haveLedger->peekAccountStateMap ().get (), true, 1024,
|
||||
BIND_TYPE (fpAppender, &reply, lSeq, P_1, P_2));
|
||||
std::bind (fpAppender, &reply, lSeq, std::placeholders::_1,
|
||||
std::placeholders::_2));
|
||||
|
||||
if (wantLedger->getTransHash ().isNonZero ())
|
||||
wantLedger->peekTransactionMap ()->getFetchPack (nullptr, true, 256,
|
||||
BIND_TYPE (fpAppender, &reply, lSeq, P_1, P_2));
|
||||
wantLedger->peekTransactionMap ()->getFetchPack (
|
||||
nullptr, true, 256,
|
||||
std::bind (fpAppender, &reply, lSeq, std::placeholders::_1,
|
||||
std::placeholders::_2));
|
||||
|
||||
if (reply.objects ().size () >= 256)
|
||||
break;
|
||||
@@ -3347,7 +3350,8 @@ void NetworkOPsImp::gotFetchPack (bool progress, std::uint32_t seq)
|
||||
// which is expensive. A flag should track whether we've already dispatched
|
||||
|
||||
getApp().getJobQueue ().addJob (jtLEDGER_DATA, "gotFetchPack",
|
||||
BIND_TYPE (&InboundLedgers::gotFetchPack, &getApp().getInboundLedgers (), P_1));
|
||||
std::bind (&InboundLedgers::gotFetchPack,
|
||||
&getApp().getInboundLedgers (), std::placeholders::_1));
|
||||
}
|
||||
|
||||
void NetworkOPsImp::missingNodeInLedger (std::uint32_t seq)
|
||||
|
||||
@@ -181,7 +181,7 @@ bool ProofOfWork::calcResultInfo (PowResult powCode, std::string& strToken, std:
|
||||
{ powOK, "powOK", "Valid proof-of-work." },
|
||||
};
|
||||
|
||||
int iIndex = NUMBER (powResultInfoA);
|
||||
int iIndex = RIPPLE_ARRAYSIZE (powResultInfoA);
|
||||
|
||||
while (iIndex-- && powResultInfoA[iIndex].powCode != powCode)
|
||||
;
|
||||
|
||||
@@ -419,7 +419,8 @@ private:
|
||||
|
||||
mWriting = true;
|
||||
getApp().getJobQueue ().addJob (jtWRITE, "Validations::doWrite",
|
||||
BIND_TYPE (&ValidationsImp::doWrite, this, P_1));
|
||||
std::bind (&ValidationsImp::doWrite,
|
||||
this, std::placeholders::_1));
|
||||
}
|
||||
|
||||
void doWrite (Job&)
|
||||
|
||||
@@ -41,7 +41,7 @@ static const char* s_nodeStoreDBInit [] =
|
||||
"END TRANSACTION;"
|
||||
};
|
||||
|
||||
static int s_nodeStoreDBCount = NUMBER (s_nodeStoreDBInit);
|
||||
static int s_nodeStoreDBCount = RIPPLE_ARRAYSIZE (s_nodeStoreDBInit);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -705,7 +705,9 @@ void Pathfinder::addLink(
|
||||
if (!candidates.empty())
|
||||
{
|
||||
std::sort (candidates.begin(), candidates.end(),
|
||||
BIND_TYPE(candCmp, mLedger->getLedgerSeq(), P_1, P_2));
|
||||
std::bind(candCmp, mLedger->getLedgerSeq(),
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2));
|
||||
|
||||
int count = candidates.size();
|
||||
if ((count > 10) && (uEndAccount != mSrcAccountID)) // allow more paths from source
|
||||
|
||||
@@ -114,7 +114,8 @@ void PeerSet::TimerEntry (boost::weak_ptr<PeerSet> wptr, const boost::system::er
|
||||
if (ptr->mTxnData)
|
||||
{
|
||||
getApp().getJobQueue ().addJob (jtTXN_DATA, "timerEntryTxn",
|
||||
BIND_TYPE (&PeerSet::TimerJobEntry, P_1, ptr));
|
||||
std::bind (&PeerSet::TimerJobEntry, std::placeholders::_1,
|
||||
ptr));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -127,7 +128,8 @@ void PeerSet::TimerEntry (boost::weak_ptr<PeerSet> wptr, const boost::system::er
|
||||
}
|
||||
else
|
||||
getApp().getJobQueue ().addJob (jtLEDGER_DATA, "timerEntryLgr",
|
||||
BIND_TYPE (&PeerSet::TimerJobEntry, P_1, ptr));
|
||||
std::bind (&PeerSet::TimerJobEntry, std::placeholders::_1,
|
||||
ptr));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,7 +182,7 @@ std::size_t PeerSet::takePeerSetFrom (const PeerSet& s)
|
||||
mPeers.insert (std::make_pair (p.first, 0));
|
||||
++ret;
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -162,12 +162,12 @@ public:
|
||||
if (timer == m_scoreTimer)
|
||||
{
|
||||
getApp().getJobQueue ().addJob (jtUNL, "UNL.score",
|
||||
BIND_TYPE (&UniqueNodeListImp::doScore, this));
|
||||
std::bind (&UniqueNodeListImp::doScore, this));
|
||||
}
|
||||
else if (timer == m_fetchTimer)
|
||||
{
|
||||
getApp().getJobQueue ().addJob (jtUNL, "UNL.fetch",
|
||||
BIND_TYPE (&UniqueNodeListImp::doFetch, this));
|
||||
std::bind (&UniqueNodeListImp::doFetch, this));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -572,7 +572,10 @@ public:
|
||||
getConfig ().VALIDATORS_URI,
|
||||
VALIDATORS_FILE_BYTES_MAX,
|
||||
boost::posix_time::seconds (VALIDATORS_FETCH_SECONDS),
|
||||
BIND_TYPE (&UniqueNodeListImp::validatorsResponse, this, P_1, P_2, P_3));
|
||||
std::bind (&UniqueNodeListImp::validatorsResponse, this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2,
|
||||
std::placeholders::_3));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1412,7 +1415,9 @@ private:
|
||||
NODE_FILE_PATH,
|
||||
NODE_FILE_BYTES_MAX,
|
||||
boost::posix_time::seconds (NODE_FETCH_SECONDS),
|
||||
BIND_TYPE (&UniqueNodeListImp::responseFetch, this, strDomain, P_1, P_2, P_3));
|
||||
std::bind (&UniqueNodeListImp::responseFetch, this, strDomain,
|
||||
std::placeholders::_1, std::placeholders::_2,
|
||||
std::placeholders::_3));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -1451,7 +1456,10 @@ private:
|
||||
strPath,
|
||||
NODE_FILE_BYTES_MAX,
|
||||
boost::posix_time::seconds (NODE_FETCH_SECONDS),
|
||||
BIND_TYPE (&UniqueNodeListImp::responseValidators, this, strValidatorsUrl, naNodePublic, secSite, strDomain, P_1, P_2, P_3));
|
||||
std::bind (&UniqueNodeListImp::responseValidators, this,
|
||||
strValidatorsUrl, naNodePublic, secSite, strDomain,
|
||||
std::placeholders::_1, std::placeholders::_2,
|
||||
std::placeholders::_3));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1485,7 +1493,9 @@ private:
|
||||
strPath,
|
||||
NODE_FILE_BYTES_MAX,
|
||||
boost::posix_time::seconds (NODE_FETCH_SECONDS),
|
||||
BIND_TYPE (&UniqueNodeListImp::responseIps, this, strDomain, naNodePublic, P_1, P_2, P_3));
|
||||
std::bind (&UniqueNodeListImp::responseIps, this, strDomain,
|
||||
naNodePublic, std::placeholders::_1,
|
||||
std::placeholders::_2, std::placeholders::_3));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -181,7 +181,7 @@ Json::Value RPCHandler::doCommand (const Json::Value& params, int iRole, Resourc
|
||||
{ "unsubscribe", &RPCHandler::doUnsubscribe, false, optNone },
|
||||
};
|
||||
|
||||
int i = NUMBER (commandsA);
|
||||
int i = RIPPLE_ARRAYSIZE (commandsA);
|
||||
|
||||
while (i-- && strCommand != commandsA[i].pCommand)
|
||||
;
|
||||
|
||||
@@ -628,7 +628,9 @@ static void addFPtoList (std::list<SHAMap::fetchPackEntry_t>& list, const uint25
|
||||
std::list<SHAMap::fetchPackEntry_t> SHAMap::getFetchPack (SHAMap* have, bool includeLeaves, int max)
|
||||
{
|
||||
std::list<fetchPackEntry_t> ret;
|
||||
getFetchPack (have, includeLeaves, max, BIND_TYPE (addFPtoList, boost::ref (ret), P_1, P_2));
|
||||
getFetchPack (have, includeLeaves, max,
|
||||
std::bind (addFPtoList, boost::ref (ret),
|
||||
std::placeholders::_1, std::placeholders::_2));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,8 +43,11 @@ void ConsensusTransSetSF::gotNode (bool fromFilter, const SHAMapNode& id, uint25
|
||||
SerializerIterator sit (s);
|
||||
SerializedTransaction::pointer stx = boost::make_shared<SerializedTransaction> (boost::ref (sit));
|
||||
assert (stx->getTransactionID () == nodeHash);
|
||||
getApp().getJobQueue ().addJob (jtTRANSACTION, "TXS->TXN",
|
||||
BIND_TYPE (&NetworkOPs::submitTransaction, &getApp().getOPs (), P_1, stx, NetworkOPs::stCallback ()));
|
||||
getApp().getJobQueue ().addJob (
|
||||
jtTRANSACTION, "TXS->TXN",
|
||||
std::bind (&NetworkOPs::submitTransaction, &getApp().getOPs (),
|
||||
std::placeholders::_1, stx,
|
||||
NetworkOPs::stCallback ()));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
@@ -193,7 +193,7 @@ std::pair<TER,bool> DirectOfferCreateTransactor::crossOffers (
|
||||
|
||||
core::Book book (
|
||||
core::AssetRef (
|
||||
saTakerPays.getCurrency(), saTakerPays.getIssuer()),
|
||||
saTakerPays.getCurrency(), saTakerPays.getIssuer()),
|
||||
core::AssetRef (
|
||||
saTakerGets.getCurrency(), saTakerGets.getIssuer()));
|
||||
|
||||
@@ -203,7 +203,7 @@ std::pair<TER,bool> DirectOfferCreateTransactor::crossOffers (
|
||||
|
||||
auto const result (process_order (
|
||||
view, book, mTxnAccountID,
|
||||
core::Amounts (saTakerPays, saTakerGets), cross_flow,
|
||||
core::Amounts (saTakerPays, saTakerGets), cross_flow,
|
||||
core::Taker::Options (mTxn.getFlags()),
|
||||
mEngine->getLedger ()->getParentCloseTimeNC (),
|
||||
m_journal));
|
||||
@@ -211,14 +211,14 @@ std::pair<TER,bool> DirectOfferCreateTransactor::crossOffers (
|
||||
core::Amounts const funds (
|
||||
view.accountFunds (mTxnAccountID, saTakerPays),
|
||||
view.accountFunds (mTxnAccountID, saTakerGets));
|
||||
|
||||
|
||||
if (m_journal.debug) m_journal.debug << " cross_flow: " <<
|
||||
cross_flow.in << ", " << cross_flow.out;
|
||||
|
||||
|
||||
if (m_journal.debug) m_journal.debug << " balances: " <<
|
||||
funds.in << ", " << funds.out;
|
||||
|
||||
saTakerPaid = cross_flow.in;
|
||||
saTakerPaid = cross_flow.in;
|
||||
saTakerGot = cross_flow.out;
|
||||
|
||||
if (m_journal.debug) m_journal.debug <<
|
||||
@@ -232,7 +232,7 @@ TER DirectOfferCreateTransactor::doApply ()
|
||||
{
|
||||
if (m_journal.debug) m_journal.debug <<
|
||||
"OfferCreate> " << mTxn.getJson (0);
|
||||
|
||||
|
||||
std::uint32_t const uTxFlags = mTxn.getFlags ();
|
||||
|
||||
bool const bPassive = is_bit_set (uTxFlags, tfPassive);
|
||||
@@ -427,7 +427,7 @@ TER DirectOfferCreateTransactor::doApply ()
|
||||
? terNO_ACCOUNT
|
||||
: tecNO_ISSUER;
|
||||
}
|
||||
|
||||
|
||||
if (is_bit_set (sleTakerPays->getFieldU32 (sfFlags), lsfRequireAuth))
|
||||
{
|
||||
SLE::pointer sleRippleState (mEngine->entryCache (
|
||||
@@ -593,7 +593,8 @@ TER DirectOfferCreateTransactor::doApply ()
|
||||
// Add offer to owner's directory.
|
||||
terResult = view.dirAdd (uOwnerNode,
|
||||
Ledger::getOwnerDirIndex (mTxnAccountID), uLedgerIndex,
|
||||
BIND_TYPE (&Ledger::ownerDirDescriber, P_1, P_2, mTxnAccountID));
|
||||
std::bind (&Ledger::ownerDirDescriber, std::placeholders::_1,
|
||||
std::placeholders::_2, mTxnAccountID));
|
||||
|
||||
if (tesSUCCESS == terResult)
|
||||
{
|
||||
@@ -618,9 +619,10 @@ TER DirectOfferCreateTransactor::doApply ()
|
||||
|
||||
// Add offer to order book.
|
||||
terResult = view.dirAdd (uBookNode, uDirectory, uLedgerIndex,
|
||||
BIND_TYPE (&Ledger::qualityDirDescriber, P_1, P_2,
|
||||
saTakerPays.getCurrency (), uPaysIssuerID,
|
||||
saTakerGets.getCurrency (), uGetsIssuerID, uRate));
|
||||
std::bind (&Ledger::qualityDirDescriber, std::placeholders::_1,
|
||||
std::placeholders::_2, saTakerPays.getCurrency (),
|
||||
uPaysIssuerID, saTakerGets.getCurrency (),
|
||||
uGetsIssuerID, uRate));
|
||||
}
|
||||
|
||||
if (tesSUCCESS == terResult)
|
||||
@@ -685,4 +687,3 @@ TER DirectOfferCreateTransactor::doApply ()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1030,7 +1030,8 @@ TER ClassicOfferCreateTransactor::doApply ()
|
||||
// Add offer to owner's directory.
|
||||
terResult = lesActive.dirAdd (uOwnerNode,
|
||||
Ledger::getOwnerDirIndex (mTxnAccountID), uLedgerIndex,
|
||||
BIND_TYPE (&Ledger::ownerDirDescriber, P_1, P_2, mTxnAccountID));
|
||||
std::bind (&Ledger::ownerDirDescriber, std::placeholders::_1,
|
||||
std::placeholders::_2, mTxnAccountID));
|
||||
|
||||
|
||||
if (tesSUCCESS == terResult)
|
||||
@@ -1055,9 +1056,10 @@ TER ClassicOfferCreateTransactor::doApply ()
|
||||
|
||||
// Add offer to order book.
|
||||
terResult = lesActive.dirAdd (uBookNode, uDirectory, uLedgerIndex,
|
||||
BIND_TYPE (&Ledger::qualityDirDescriber, P_1, P_2,
|
||||
saTakerPays.getCurrency (), uPaysIssuerID,
|
||||
saTakerGets.getCurrency (), uGetsIssuerID, uRate));
|
||||
std::bind (&Ledger::qualityDirDescriber, std::placeholders::_1,
|
||||
std::placeholders::_2, saTakerPays.getCurrency (),
|
||||
uPaysIssuerID, saTakerGets.getCurrency (), uGetsIssuerID,
|
||||
uRate));
|
||||
}
|
||||
|
||||
if (tesSUCCESS == terResult)
|
||||
|
||||
@@ -75,7 +75,7 @@ void TransactionAcquire::done ()
|
||||
map = mMap;
|
||||
}
|
||||
|
||||
getApp().getJobQueue().addJob (jtTXN_DATA, "completeAcquire", BIND_TYPE (&TACompletionHandler, mHash, map));
|
||||
getApp().getJobQueue().addJob (jtTXN_DATA, "completeAcquire", std::bind (&TACompletionHandler, mHash, map));
|
||||
}
|
||||
|
||||
void TransactionAcquire::onTimer (bool progress, ScopedLockType& psl)
|
||||
|
||||
@@ -121,13 +121,13 @@ public:
|
||||
|
||||
void send (connection_ptr cpClient, message_ptr mpMessage)
|
||||
{
|
||||
cpClient->get_strand ().post (BIND_TYPE (
|
||||
cpClient->get_strand ().post (std::bind (
|
||||
&WSServerHandler<endpoint_type>::ssend, cpClient, mpMessage));
|
||||
}
|
||||
|
||||
void send (connection_ptr cpClient, const std::string& strMessage, bool broadcast)
|
||||
{
|
||||
cpClient->get_strand ().post (BIND_TYPE (
|
||||
cpClient->get_strand ().post (std::bind (
|
||||
&WSServerHandler<endpoint_type>::ssendb, cpClient, strMessage, broadcast));
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ public:
|
||||
|
||||
// Must be done without holding the websocket send lock
|
||||
getApp().getJobQueue ().addJob (jtCLIENT, "WSClient::destroy",
|
||||
BIND_TYPE (&WSConnectionType <endpoint_type>::destroy, ptr));
|
||||
std::bind (&WSConnectionType <endpoint_type>::destroy, ptr));
|
||||
}
|
||||
|
||||
void on_message (connection_ptr cpClient, message_ptr mpMessage)
|
||||
@@ -310,7 +310,8 @@ public:
|
||||
|
||||
if (bRunQ)
|
||||
getApp().getJobQueue ().addJob (jtCLIENT, "WSClient::command",
|
||||
BIND_TYPE (&WSServerHandler<endpoint_type>::do_messages, this, P_1, cpClient));
|
||||
std::bind (&WSServerHandler<endpoint_type>::do_messages,
|
||||
this, std::placeholders::_1, cpClient));
|
||||
}
|
||||
|
||||
void do_messages (Job& job, connection_ptr cpClient)
|
||||
@@ -345,8 +346,10 @@ public:
|
||||
}
|
||||
|
||||
if (ptr->checkMessage ())
|
||||
getApp().getJobQueue ().addJob (jtCLIENT, "WSClient::more",
|
||||
BIND_TYPE (&WSServerHandler<endpoint_type>::do_messages, this, P_1, cpClient));
|
||||
getApp().getJobQueue ().addJob (
|
||||
jtCLIENT, "WSClient::more",
|
||||
std::bind (&WSServerHandler<endpoint_type>::do_messages, this,
|
||||
std::placeholders::_1, cpClient));
|
||||
}
|
||||
|
||||
bool do_message (Job& job, const connection_ptr& cpClient, const wsc_ptr& conn, const message_ptr& mpMessage)
|
||||
|
||||
@@ -25,28 +25,23 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
#define BIND_TYPE std::bind
|
||||
#define P_1 std::placeholders::_1
|
||||
#define P_2 std::placeholders::_2
|
||||
#define P_3 std::placeholders::_3
|
||||
#define P_4 std::placeholders::_4
|
||||
|
||||
template <typename X, typename Y>
|
||||
inline
|
||||
std::enable_if_t<
|
||||
(std::is_integral<X>::value || std::is_enum<X>::value) &&
|
||||
(std::is_integral<Y>::value || std::is_enum<Y>::value),
|
||||
(std::is_integral<X>::value || std::is_enum<X>::value) &&
|
||||
(std::is_integral<Y>::value || std::is_enum<Y>::value),
|
||||
bool>
|
||||
is_bit_set(X const x, Y const y)
|
||||
{
|
||||
return (x & y);
|
||||
if (x & y)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// VFALCO TODO Clean this stuff up. Remove as much as possible
|
||||
// DEPRECATED
|
||||
#define nothing() do {} while (0)
|
||||
#define NUMBER(x) (sizeof(x)/sizeof((x)[0]))
|
||||
#define is_bit_set(x,y) (!!((x) & (y)))
|
||||
#define RIPPLE_ARRAYSIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
} // ripple
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ bool transResultInfo (TER terCode, std::string& strToken, std::string& strHuman)
|
||||
{ tesSUCCESS, "tesSUCCESS", "The transaction was applied." },
|
||||
};
|
||||
|
||||
int iIndex = NUMBER (transResultInfoA);
|
||||
int iIndex = RIPPLE_ARRAYSIZE (transResultInfoA);
|
||||
|
||||
while (iIndex-- && transResultInfoA[iIndex].terCode != terCode)
|
||||
;
|
||||
|
||||
@@ -151,7 +151,8 @@ public:
|
||||
request (
|
||||
bSSL,
|
||||
deqSites,
|
||||
BIND_TYPE (&HTTPClientImp::makeGet, shared_from_this (), strPath, P_1, P_2),
|
||||
std::bind (&HTTPClientImp::makeGet, shared_from_this (), strPath,
|
||||
std::placeholders::_1, std::placeholders::_2),
|
||||
timeout,
|
||||
complete);
|
||||
}
|
||||
@@ -406,7 +407,7 @@ public:
|
||||
// no body wanted or available
|
||||
invokeComplete (ecResult, mStatus);
|
||||
}
|
||||
else if (mBody.size () >= mResponseMax)
|
||||
else if (mBody.size () >= mResponseMax)
|
||||
{
|
||||
// we got the whole thing
|
||||
invokeComplete (ecResult, mStatus, mBody);
|
||||
@@ -611,9 +612,10 @@ void HTTPClient::sendSMS (boost::asio::io_service& io_service, const std::string
|
||||
new HTTPClientImp (io_service, iPort, maxClientHeaderBytes));
|
||||
|
||||
client->get (bSSL, deqSites, strURI, boost::posix_time::seconds (smsTimeoutSeconds),
|
||||
BIND_TYPE (&HTTPClientImp::onSMSResponse, P_1, P_2, P_3));
|
||||
std::bind (&HTTPClientImp::onSMSResponse,
|
||||
std::placeholders::_1, std::placeholders::_2,
|
||||
std::placeholders::_3));
|
||||
}
|
||||
}
|
||||
|
||||
} // ripple
|
||||
|
||||
|
||||
@@ -857,7 +857,7 @@ public:
|
||||
{ "unsubscribe", &RPCParser::parseEvented, -1, -1 },
|
||||
};
|
||||
|
||||
int i = NUMBER (commandsA);
|
||||
int i = RIPPLE_ARRAYSIZE (commandsA);
|
||||
|
||||
while (i-- && strMethod != commandsA[i].pCommand)
|
||||
;
|
||||
@@ -1008,7 +1008,8 @@ int RPCCall::fromCommandLine (const std::vector<std::string>& vCmd)
|
||||
? jvRequest["method"].asString () : vCmd[0],
|
||||
jvParams, // Parsed, execute.
|
||||
false,
|
||||
BIND_TYPE (RPCCallImp::callRPCHandler, &jvOutput, P_1));
|
||||
std::bind (RPCCallImp::callRPCHandler, &jvOutput,
|
||||
std::placeholders::_1));
|
||||
|
||||
isService.run (); // This blocks until there is no more outstanding async calls.
|
||||
|
||||
@@ -1105,15 +1106,17 @@ void RPCCall::fromNetwork (
|
||||
io_service,
|
||||
strIp,
|
||||
iPort,
|
||||
BIND_TYPE (
|
||||
std::bind (
|
||||
&RPCCallImp::onRequest,
|
||||
strMethod,
|
||||
jvParams,
|
||||
mapRequestHeaders,
|
||||
strPath, P_1, P_2),
|
||||
strPath, std::placeholders::_1, std::placeholders::_2),
|
||||
RPC_REPLY_MAX_BYTES,
|
||||
boost::posix_time::seconds (RPC_NOTIFY_SECONDS),
|
||||
BIND_TYPE (&RPCCallImp::onResponse, callbackFuncP, P_1, P_2, P_3));
|
||||
std::bind (&RPCCallImp::onResponse, callbackFuncP,
|
||||
std::placeholders::_1, std::placeholders::_2,
|
||||
std::placeholders::_3));
|
||||
}
|
||||
|
||||
} // ripple
|
||||
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
WriteLog (lsINFO, RPCSub) << "RPCCall::fromNetwork start";
|
||||
|
||||
m_jobQueue.addJob (
|
||||
jtCLIENT, "RPCSub::sendThread", BIND_TYPE (&RPCSubImp::sendThread, this));
|
||||
jtCLIENT, "RPCSub::sendThread", std::bind (&RPCSubImp::sendThread, this));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ std::ostream& operator<< (std::ostream& os, PeerImp const* peer);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
class PeerImp
|
||||
class PeerImp
|
||||
: public Peer
|
||||
, public boost::enable_shared_from_this <PeerImp>
|
||||
, private beast::LeakChecked <Peer>
|
||||
@@ -239,7 +239,7 @@ public:
|
||||
, m_was_canceled (false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/** New outgoing peer
|
||||
@note Construction of outbound peers is a two step process: a second
|
||||
call is needed (to connect or accept) but we cannot make it from
|
||||
@@ -276,7 +276,7 @@ public:
|
||||
, m_was_canceled (false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual
|
||||
~PeerImp ()
|
||||
{
|
||||
@@ -318,7 +318,7 @@ public:
|
||||
{
|
||||
if (! m_strand.running_in_this_thread ())
|
||||
{
|
||||
m_strand.post (BIND_TYPE (&PeerImp::detach,
|
||||
m_strand.post (std::bind (&PeerImp::detach,
|
||||
shared_from_this (), rsn, graceful));
|
||||
return;
|
||||
}
|
||||
@@ -333,7 +333,7 @@ public:
|
||||
m_peerFinder.on_cancel (m_slot);
|
||||
else
|
||||
m_peerFinder.on_closed (m_slot);
|
||||
|
||||
|
||||
if (m_state == stateActive)
|
||||
m_overlay.onPeerDisconnect (shared_from_this ());
|
||||
|
||||
@@ -458,7 +458,7 @@ public:
|
||||
{
|
||||
if (!onStrand)
|
||||
{
|
||||
m_strand.post (BIND_TYPE (
|
||||
m_strand.post (std::bind (
|
||||
&Peer::sendPacket, shared_from_this (), packet, true));
|
||||
return;
|
||||
}
|
||||
@@ -743,7 +743,7 @@ private:
|
||||
Application::ScopedLockType lock (getApp ().getMasterLock ());
|
||||
detach ("hrb");
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1043,7 +1043,7 @@ private:
|
||||
case protocol::mtGET_LEDGER:
|
||||
{
|
||||
event->reName ("Peer::getledger");
|
||||
boost::shared_ptr<protocol::TMGetLedger> msg (
|
||||
boost::shared_ptr<protocol::TMGetLedger> msg (
|
||||
boost::make_shared<protocol::TMGetLedger> ());
|
||||
|
||||
if (msg->ParseFromArray (&m_readBuffer[Message::kHeaderBytes],
|
||||
@@ -1298,7 +1298,7 @@ private:
|
||||
@return true if successful, false otherwise.
|
||||
*/
|
||||
bool sendHello ()
|
||||
{
|
||||
{
|
||||
if (!calculateSessionCookie())
|
||||
return false;
|
||||
|
||||
@@ -1535,8 +1535,9 @@ private:
|
||||
else
|
||||
getApp().getJobQueue ().addJob (jtTRANSACTION,
|
||||
"recvTransaction->checkTransaction",
|
||||
BIND_TYPE (
|
||||
&PeerImp::checkTransaction, P_1, flags, stx,
|
||||
std::bind (
|
||||
&PeerImp::checkTransaction, std::placeholders::_1,
|
||||
flags, stx,
|
||||
boost::weak_ptr<Peer> (shared_from_this ())));
|
||||
|
||||
#ifndef TRUST_NETWORK
|
||||
@@ -1588,9 +1589,9 @@ private:
|
||||
getApp().getJobQueue ().addJob (
|
||||
isTrusted ? jtVALIDATION_t : jtVALIDATION_ut,
|
||||
"recvValidation->checkValidation",
|
||||
BIND_TYPE (
|
||||
&PeerImp::checkValidation, P_1, &m_overlay, val,
|
||||
isTrusted, m_clusterNode, packet,
|
||||
std::bind (
|
||||
&PeerImp::checkValidation, std::placeholders::_1,
|
||||
&m_overlay, val, isTrusted, m_clusterNode, packet,
|
||||
boost::weak_ptr<Peer> (shared_from_this ())));
|
||||
}
|
||||
else
|
||||
@@ -1690,7 +1691,7 @@ private:
|
||||
endpoint.address = m_remoteAddress.at_port (
|
||||
tm.ipv4().ipv4port ());
|
||||
}
|
||||
|
||||
|
||||
endpoints.push_back (endpoint);
|
||||
}
|
||||
|
||||
@@ -1817,7 +1818,7 @@ private:
|
||||
{
|
||||
packet.set_type (protocol::TMPing::ptPONG);
|
||||
sendPacket (boost::make_shared<Message> (packet, protocol::mtPING), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void recvErrorMessage (protocol::TMErrorMsg& packet)
|
||||
@@ -1930,7 +1931,7 @@ private:
|
||||
// got data for a candidate transaction set
|
||||
|
||||
getApp().getJobQueue().addJob (jtTXN_DATA, "recvPeerData",
|
||||
BIND_TYPE (&PeerImp::peerTXData, P_1,
|
||||
std::bind (&PeerImp::peerTXData, std::placeholders::_1,
|
||||
boost::weak_ptr<Peer> (shared_from_this ()),
|
||||
hash, packet_ptr, m_journal));
|
||||
|
||||
@@ -2067,20 +2068,21 @@ private:
|
||||
" proposal from " << m_shortId;
|
||||
|
||||
uint256 consensusLCL;
|
||||
|
||||
|
||||
{
|
||||
Application::ScopedLockType lock (getApp ().getMasterLock ());
|
||||
consensusLCL = getApp().getOPs ().getConsensusLCL ();
|
||||
}
|
||||
|
||||
|
||||
LedgerProposal::pointer proposal = boost::make_shared<LedgerProposal> (
|
||||
prevLedger.isNonZero () ? prevLedger : consensusLCL,
|
||||
set.proposeseq (), proposeHash, set.closetime (), signerPublic, suppression);
|
||||
|
||||
getApp().getJobQueue ().addJob (isTrusted ? jtPROPOSAL_t : jtPROPOSAL_ut,
|
||||
"recvPropose->checkPropose", BIND_TYPE (
|
||||
&PeerImp::checkPropose, P_1, &m_overlay, packet, proposal, consensusLCL,
|
||||
m_nodePublicKey, boost::weak_ptr<Peer> (shared_from_this ()), m_clusterNode));
|
||||
"recvPropose->checkPropose", std::bind (
|
||||
&PeerImp::checkPropose, std::placeholders::_1, &m_overlay,
|
||||
packet, proposal, consensusLCL, m_nodePublicKey,
|
||||
boost::weak_ptr<Peer> (shared_from_this ()), m_clusterNode));
|
||||
}
|
||||
|
||||
void recvHaveTxSet (protocol::TMHaveTransactionSet& packet)
|
||||
@@ -2105,7 +2107,7 @@ private:
|
||||
|
||||
{
|
||||
Application::ScopedLockType lock (getApp ().getMasterLock ());
|
||||
|
||||
|
||||
if (!getApp().getOPs ().hasTXSet (shared_from_this (), hash, packet.status ()))
|
||||
charge (Resource::feeUnwantedData);
|
||||
}
|
||||
@@ -2179,7 +2181,8 @@ private:
|
||||
getApp().getJobQueue ().addJob (
|
||||
jtPROOFWORK,
|
||||
"recvProof->doProof",
|
||||
BIND_TYPE (&PeerImp::doProofOfWork, P_1, boost::weak_ptr <Peer> (shared_from_this ()), pow));
|
||||
std::bind (&PeerImp::doProofOfWork, std::placeholders::_1,
|
||||
boost::weak_ptr <Peer> (shared_from_this ()), pow));
|
||||
#endif
|
||||
|
||||
return;
|
||||
@@ -2201,7 +2204,7 @@ private:
|
||||
|
||||
m_recentLedgers.push_back (hash);
|
||||
}
|
||||
|
||||
|
||||
void getLedger (protocol::TMGetLedger& packet)
|
||||
{
|
||||
SHAMap::pointer map;
|
||||
@@ -2216,7 +2219,7 @@ private:
|
||||
if (packet.itype () == protocol::liTS_CANDIDATE)
|
||||
{
|
||||
// Request is for a transaction candidate set
|
||||
m_journal.trace << "Received request for TX candidate set data "
|
||||
m_journal.trace << "Received request for TX candidate set data "
|
||||
<< to_string (this);
|
||||
|
||||
if ((!packet.has_ledgerhash () || packet.ledgerhash ().size () != 32))
|
||||
@@ -2281,7 +2284,7 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
m_journal.error << "We do not have the map our peer wants "
|
||||
m_journal.error << "We do not have the map our peer wants "
|
||||
<< to_string (this);
|
||||
|
||||
charge (Resource::feeInvalidRequest);
|
||||
@@ -2525,28 +2528,28 @@ private:
|
||||
}
|
||||
|
||||
Message::pointer oPacket = boost::make_shared<Message> (reply, protocol::mtLEDGER_DATA);
|
||||
sendPacket (oPacket, false);
|
||||
sendPacket (oPacket, false);
|
||||
}
|
||||
|
||||
|
||||
// This is dispatched by the job queue
|
||||
static
|
||||
void
|
||||
sGetLedger (boost::weak_ptr<PeerImp> wPeer,
|
||||
sGetLedger (boost::weak_ptr<PeerImp> wPeer,
|
||||
boost::shared_ptr <protocol::TMGetLedger> packet)
|
||||
{
|
||||
boost::shared_ptr<PeerImp> peer = wPeer.lock ();
|
||||
|
||||
|
||||
if (peer)
|
||||
peer->getLedger (*packet);
|
||||
}
|
||||
|
||||
|
||||
void addTxSet (uint256 const& hash)
|
||||
{
|
||||
boost::mutex::scoped_lock sl(m_recentLock);
|
||||
|
||||
if(std::find (m_recentTxSets.begin (), m_recentTxSets.end (), hash) != m_recentTxSets.end ())
|
||||
return;
|
||||
|
||||
|
||||
if (m_recentTxSets.size () == 128)
|
||||
m_recentTxSets.pop_front ();
|
||||
|
||||
@@ -2577,7 +2580,7 @@ private:
|
||||
memcpy (hash.begin (), packet->ledgerhash ().data (), 32);
|
||||
|
||||
getApp().getJobQueue ().addJob (jtPACK, "MakeFetchPack",
|
||||
BIND_TYPE (&NetworkOPs::makeFetchPack, &getApp().getOPs (), P_1,
|
||||
std::bind (&NetworkOPs::makeFetchPack, &getApp().getOPs (), std::placeholders::_1,
|
||||
boost::weak_ptr<Peer> (shared_from_this ()), packet,
|
||||
hash, UptimeTimer::getInstance ().getElapsedSeconds ()));
|
||||
}
|
||||
@@ -2769,7 +2772,7 @@ private:
|
||||
{
|
||||
pPeers->foreach (send_if_not (
|
||||
boost::make_shared<Message> (*packet, protocol::mtVALIDATION),
|
||||
peer_in_set(peers)));
|
||||
peer_in_set(peers)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,9 @@ Json::Value RPCHandler::doAccountOffers (Json::Value params, Resource::Charge& l
|
||||
return rpcError (rpcACT_NOT_FOUND);
|
||||
|
||||
Json::Value& jvsOffers = (jvResult[jss::offers] = Json::arrayValue);
|
||||
lpLedger->visitAccountItems (raAccount.getAccountID (), BIND_TYPE (&offerAdder, boost::ref (jvsOffers), P_1));
|
||||
lpLedger->visitAccountItems (raAccount.getAccountID (),
|
||||
std::bind (&offerAdder, boost::ref (jvsOffers),
|
||||
std::placeholders::_1));
|
||||
|
||||
loadType = Resource::feeMediumBurdenRPC;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user