mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-21 19:45:53 +00:00
Modernize code:
* Clean STBase-derived class creation interfaces * Annotate overriden STBase virtual functions * Optimize path deserialization * Prefer range-based for * Prefer std::unique_ptr * Remove BOOST_FOREACH
This commit is contained in:
0
Builds/VisualStudio2013/RippleD.vcxproj
Executable file → Normal file
0
Builds/VisualStudio2013/RippleD.vcxproj
Executable file → Normal file
0
Builds/VisualStudio2013/RippleD.vcxproj.filters
Executable file → Normal file
0
Builds/VisualStudio2013/RippleD.vcxproj.filters
Executable file → Normal file
@@ -54,10 +54,9 @@ OfferStream::erase (LedgerView& view)
|
||||
}
|
||||
|
||||
auto v (p->getFieldV256 (sfIndexes));
|
||||
auto& x (v.peekValue());
|
||||
auto it (std::find (x.begin(), x.end(), m_tip.index()));
|
||||
auto it (std::find (v.begin(), v.end(), m_tip.index()));
|
||||
|
||||
if (it == x.end())
|
||||
if (it == v.end())
|
||||
{
|
||||
if (m_journal.error) m_journal.error <<
|
||||
"Missing offer " << m_tip.index() <<
|
||||
@@ -65,7 +64,7 @@ OfferStream::erase (LedgerView& view)
|
||||
return;
|
||||
}
|
||||
|
||||
x.erase (it);
|
||||
v.erase (it);
|
||||
p->setFieldV256 (sfIndexes, v);
|
||||
view.entryModify (p);
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <ripple/app/ledger/LedgerEntrySet.h>
|
||||
#include <ripple/basics/StringUtilities.h>
|
||||
#include <ripple/protocol/JsonFields.h>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -84,7 +83,7 @@ void AcceptedLedgerTx::buildJson ()
|
||||
if (!mAffected.empty ())
|
||||
{
|
||||
Json::Value& affected = (mJson[jss::affected] = Json::arrayValue);
|
||||
BOOST_FOREACH (const RippleAddress & ra, mAffected)
|
||||
for (auto const& ra : mAffected)
|
||||
{
|
||||
affected.append (ra.humanAccountID ());
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include <ripple/resource/Fees.h>
|
||||
#include <ripple/protocol/HashPrefix.h>
|
||||
#include <ripple/nodestore/Database.h>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -604,9 +603,9 @@ void InboundLedger::trigger (Peer::ptr const& peer)
|
||||
if (!nodeIDs.empty ())
|
||||
{
|
||||
tmGL.set_itype (protocol::liAS_NODE);
|
||||
BOOST_FOREACH (SHAMapNodeID const& it, nodeIDs)
|
||||
for (auto const& id : nodeIDs)
|
||||
{
|
||||
* (tmGL.add_nodeids ()) = it.getRawString ();
|
||||
* (tmGL.add_nodeids ()) = id.getRawString ();
|
||||
}
|
||||
if (m_journal.trace) m_journal.trace <<
|
||||
"Sending AS node " << nodeIDs.size () <<
|
||||
@@ -675,9 +674,9 @@ void InboundLedger::trigger (Peer::ptr const& peer)
|
||||
if (!nodeIDs.empty ())
|
||||
{
|
||||
tmGL.set_itype (protocol::liTX_NODE);
|
||||
BOOST_FOREACH (SHAMapNodeID const& it, nodeIDs)
|
||||
for (auto const& id : nodeIDs)
|
||||
{
|
||||
* (tmGL.add_nodeids ()) = it.getRawString ();
|
||||
* (tmGL.add_nodeids ()) = id.getRawString ();
|
||||
}
|
||||
if (m_journal.trace) m_journal.trace <<
|
||||
"Sending TX node " << nodeIDs.size () <<
|
||||
@@ -716,7 +715,7 @@ void InboundLedger::filterNodes (std::vector<SHAMapNodeID>& nodeIDs,
|
||||
|
||||
int dupCount = 0;
|
||||
|
||||
BOOST_FOREACH(SHAMapNodeID const& nodeID, nodeIDs)
|
||||
for(auto const& nodeID : nodeIDs)
|
||||
{
|
||||
if (recentNodes.count (nodeID) != 0)
|
||||
{
|
||||
@@ -769,7 +768,7 @@ void InboundLedger::filterNodes (std::vector<SHAMapNodeID>& nodeIDs,
|
||||
nodeHashes.resize (max);
|
||||
}
|
||||
|
||||
BOOST_FOREACH (const SHAMapNodeID & n, nodeIDs)
|
||||
for (auto const& n : nodeIDs)
|
||||
{
|
||||
recentNodes.insert (n);
|
||||
}
|
||||
|
||||
@@ -1264,7 +1264,7 @@ void Ledger::visitAccountItems (
|
||||
if (!ownerDir || (ownerDir->getType () != ltDIR_NODE))
|
||||
return;
|
||||
|
||||
for (auto const& node : ownerDir->getFieldV256 (sfIndexes).peekValue ())
|
||||
for (auto const& node : ownerDir->getFieldV256 (sfIndexes))
|
||||
{
|
||||
func (getSLEi (node));
|
||||
}
|
||||
@@ -1621,13 +1621,13 @@ Ledger::LedgerHashes Ledger::getLedgerHashes () const
|
||||
|
||||
std::vector<uint256> Ledger::getLedgerAmendments () const
|
||||
{
|
||||
std::vector<uint256> usAmendments;
|
||||
std::vector<uint256> amendments;
|
||||
SLE::pointer sleAmendments = getSLEi (getLedgerAmendmentIndex ());
|
||||
|
||||
if (sleAmendments)
|
||||
usAmendments = sleAmendments->getFieldV256 (sfAmendments).peekValue ();
|
||||
amendments = static_cast<decltype(amendments)> (sleAmendments->getFieldV256 (sfAmendments));
|
||||
|
||||
return usAmendments;
|
||||
return amendments;
|
||||
}
|
||||
|
||||
bool Ledger::walkLedger () const
|
||||
@@ -1701,7 +1701,7 @@ void Ledger::updateSkipList ()
|
||||
if (!skipList)
|
||||
skipList = std::make_shared<SLE> (ltLEDGER_HASHES, hash);
|
||||
else
|
||||
hashes = skipList->getFieldV256 (sfHashes).peekValue ();
|
||||
hashes = static_cast<decltype(hashes)> (skipList->getFieldV256 (sfHashes));
|
||||
|
||||
assert (hashes.size () <= 256);
|
||||
hashes.push_back (mParentHash);
|
||||
@@ -1722,13 +1722,9 @@ void Ledger::updateSkipList ()
|
||||
std::vector <uint256> hashes;
|
||||
|
||||
if (!skipList)
|
||||
{
|
||||
skipList = std::make_shared<SLE> (ltLEDGER_HASHES, hash);
|
||||
}
|
||||
else
|
||||
{
|
||||
hashes = skipList->getFieldV256 (sfHashes).peekValue ();
|
||||
}
|
||||
hashes = static_cast<decltype(hashes)>(skipList->getFieldV256 (sfHashes));
|
||||
|
||||
assert (hashes.size () <= 256);
|
||||
|
||||
|
||||
@@ -599,7 +599,7 @@ TER LedgerEntrySet::dirCount (uint256 const& uRootIndex, std::uint32_t& uCount)
|
||||
|
||||
if (sleNode)
|
||||
{
|
||||
uCount += sleNode->getFieldV256 (sfIndexes).peekValue ().size ();
|
||||
uCount += sleNode->getFieldV256 (sfIndexes).size ();
|
||||
|
||||
uNodeDir = sleNode->getFieldU64 (sfIndexNext); // Get next node.
|
||||
}
|
||||
@@ -626,7 +626,7 @@ bool LedgerEntrySet::dirIsEmpty (uint256 const& uRootIndex)
|
||||
if (!sleNode)
|
||||
return true;
|
||||
|
||||
if (!sleNode->getFieldV256 (sfIndexes).peekValue ().empty ())
|
||||
if (!sleNode->getFieldV256 (sfIndexes).empty ())
|
||||
return false;
|
||||
|
||||
// If there's another page, it must be non-empty
|
||||
@@ -681,7 +681,7 @@ TER LedgerEntrySet::dirAdd (
|
||||
|
||||
svIndexes = sleNode->getFieldV256 (sfIndexes);
|
||||
|
||||
if (DIR_NODE_MAX != svIndexes.peekValue ().size ())
|
||||
if (DIR_NODE_MAX != svIndexes.size ())
|
||||
{
|
||||
// Add to current node.
|
||||
entryModify (sleNode);
|
||||
@@ -714,7 +714,7 @@ TER LedgerEntrySet::dirAdd (
|
||||
}
|
||||
}
|
||||
|
||||
svIndexes.peekValue ().push_back (uLedgerIndex); // Append entry.
|
||||
svIndexes.push_back (uLedgerIndex); // Append entry.
|
||||
sleNode->setFieldV256 (sfIndexes, svIndexes); // Save entry.
|
||||
|
||||
WriteLog (lsTRACE, LedgerEntrySet) <<
|
||||
@@ -723,7 +723,6 @@ TER LedgerEntrySet::dirAdd (
|
||||
"dirAdd: appending: Entry: " << to_string (uLedgerIndex);
|
||||
WriteLog (lsTRACE, LedgerEntrySet) <<
|
||||
"dirAdd: appending: Node: " << strHex (uNodeDir);
|
||||
// WriteLog (lsINFO, LedgerEntrySet) << "dirAdd: appending: PREV: " << svIndexes.peekValue()[0].ToString();
|
||||
|
||||
return tesSUCCESS;
|
||||
}
|
||||
@@ -765,55 +764,50 @@ TER LedgerEntrySet::dirDelete (
|
||||
}
|
||||
|
||||
STVector256 svIndexes = sleNode->getFieldV256 (sfIndexes);
|
||||
std::vector<uint256>& vuiIndexes = svIndexes.peekValue ();
|
||||
|
||||
auto it = std::find (vuiIndexes.begin (), vuiIndexes.end (), uLedgerIndex);
|
||||
auto it = std::find (svIndexes.begin (), svIndexes.end (), uLedgerIndex);
|
||||
|
||||
if (vuiIndexes.end () == it)
|
||||
if (svIndexes.end () == it)
|
||||
{
|
||||
if (!bSoft)
|
||||
{
|
||||
assert (false);
|
||||
|
||||
WriteLog (lsWARNING, LedgerEntrySet) << "dirDelete: no such entry";
|
||||
|
||||
return tefBAD_LEDGER;
|
||||
}
|
||||
else if (uNodeDir < 20)
|
||||
|
||||
if (uNodeDir < 20)
|
||||
{
|
||||
// Go the extra mile. Even if entry not in node, try the next node.
|
||||
|
||||
return dirDelete (bKeepRoot, uNodeDir + 1, uRootIndex, uLedgerIndex,
|
||||
bStable, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return tefBAD_LEDGER;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the element.
|
||||
if (vuiIndexes.size () > 1)
|
||||
if (svIndexes.size () > 1)
|
||||
{
|
||||
if (bStable)
|
||||
{
|
||||
vuiIndexes.erase (it);
|
||||
svIndexes.erase (it);
|
||||
}
|
||||
else
|
||||
{
|
||||
*it = vuiIndexes[vuiIndexes.size () - 1];
|
||||
vuiIndexes.resize (vuiIndexes.size () - 1);
|
||||
*it = svIndexes[svIndexes.size () - 1];
|
||||
svIndexes.resize (svIndexes.size () - 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vuiIndexes.clear ();
|
||||
svIndexes.clear ();
|
||||
}
|
||||
|
||||
sleNode->setFieldV256 (sfIndexes, svIndexes);
|
||||
entryModify (sleNode);
|
||||
|
||||
if (vuiIndexes.empty ())
|
||||
if (svIndexes.empty ())
|
||||
{
|
||||
// May be able to delete nodes.
|
||||
std::uint64_t uNodePrevious = sleNode->getFieldU64 (sfIndexPrevious);
|
||||
@@ -844,7 +838,7 @@ TER LedgerEntrySet::dirDelete (
|
||||
|
||||
assert (sleLast);
|
||||
|
||||
if (sleLast->getFieldV256 (sfIndexes).peekValue ().empty ())
|
||||
if (sleLast->getFieldV256 (sfIndexes).empty ())
|
||||
{
|
||||
// Both nodes are empty.
|
||||
|
||||
@@ -908,7 +902,7 @@ TER LedgerEntrySet::dirDelete (
|
||||
|
||||
assert (sleRoot);
|
||||
|
||||
if (sleRoot->getFieldV256 (sfIndexes).peekValue ().empty ())
|
||||
if (sleRoot->getFieldV256 (sfIndexes).empty ())
|
||||
{
|
||||
// Both nodes are empty.
|
||||
|
||||
@@ -950,11 +944,10 @@ bool LedgerEntrySet::dirNext (
|
||||
uint256& uEntryIndex) // <-- The entry, if available. Otherwise, zero.
|
||||
{
|
||||
STVector256 svIndexes = sleNode->getFieldV256 (sfIndexes);
|
||||
std::vector<uint256>& vuiIndexes = svIndexes.peekValue ();
|
||||
|
||||
assert (uDirEntry <= vuiIndexes.size ());
|
||||
assert (uDirEntry <= svIndexes.size ());
|
||||
|
||||
if (uDirEntry >= vuiIndexes.size ())
|
||||
if (uDirEntry >= svIndexes.size ())
|
||||
{
|
||||
std::uint64_t uNodeNext = sleNode->getFieldU64 (sfIndexNext);
|
||||
|
||||
@@ -983,7 +976,7 @@ bool LedgerEntrySet::dirNext (
|
||||
}
|
||||
}
|
||||
|
||||
uEntryIndex = vuiIndexes[uDirEntry++];
|
||||
uEntryIndex = svIndexes[uDirEntry++];
|
||||
|
||||
WriteLog (lsTRACE, LedgerEntrySet) << "dirNext:" <<
|
||||
" uDirEntry=" << uDirEntry <<
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <ripple/core/ConfigSections.h>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/tokenizer.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
namespace ripple {
|
||||
/** Track the list of "amendments"
|
||||
@@ -498,16 +499,19 @@ void
|
||||
AmendmentTableImpl<AppApiFacade>::doValidation (Ledger::ref lastClosedLedger,
|
||||
STObject& baseValidation)
|
||||
{
|
||||
amendmentList_t lAmendments = getDesired();
|
||||
auto lAmendments = getDesired();
|
||||
|
||||
if (lAmendments.empty())
|
||||
return;
|
||||
|
||||
STVector256 vAmendments (sfAmendments);
|
||||
for (auto const& uAmendment : lAmendments)
|
||||
vAmendments.push_back (uAmendment);
|
||||
vAmendments.sort ();
|
||||
baseValidation.setFieldV256 (sfAmendments, vAmendments);
|
||||
STVector256 amendments (sfAmendments);
|
||||
|
||||
for (auto const& id : lAmendments)
|
||||
amendments.push_back (id);
|
||||
|
||||
std::sort (amendments.begin (), amendments.end ());
|
||||
|
||||
baseValidation.setFieldV256 (sfAmendments, amendments);
|
||||
}
|
||||
|
||||
template<class AppApiFacade>
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <ripple/basics/CountedObject.h>
|
||||
#include <ripple/basics/UnorderedContainers.h>
|
||||
#include <ripple/basics/UptimeTimer.h>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
|
||||
@@ -146,7 +145,7 @@ HashRouter::Entry& HashRouter::findCreateEntry (uint256 const& index, bool& crea
|
||||
|
||||
if ((it != mSuppressionTimes.end ()) && (it->first <= expireTime))
|
||||
{
|
||||
BOOST_FOREACH (uint256 const& lit, it->second)
|
||||
for(auto const& lit : it->second)
|
||||
mSuppressionMap.erase (lit);
|
||||
mSuppressionTimes.erase (it);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,6 @@
|
||||
#include <beast/module/core/thread/DeadlineTimer.h>
|
||||
#include <beast/module/core/system/SystemStats.h>
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <tuple>
|
||||
|
||||
namespace ripple {
|
||||
@@ -1738,9 +1737,10 @@ void NetworkOPsImp::endConsensus (bool correctLCL)
|
||||
{
|
||||
uint256 deadLedger = m_ledgerMaster.getClosedLedger ()->getParentHash ();
|
||||
|
||||
// Why do we make a copy of the peer list here?
|
||||
std::vector <Peer::ptr> peerList = getApp().overlay ().getActivePeers ();
|
||||
|
||||
BOOST_FOREACH (Peer::ptr const& it, peerList)
|
||||
for (auto const& it : peerList)
|
||||
{
|
||||
if (it && (it->getClosedLedgerHash () == deadLedger))
|
||||
{
|
||||
@@ -2582,7 +2582,7 @@ void NetworkOPsImp::pubLedger (Ledger::ref accepted)
|
||||
}
|
||||
|
||||
// Don't lock since pubAcceptedTransaction is locking.
|
||||
BOOST_FOREACH (const AcceptedLedger::value_type & vt, alpAccepted->getMap ())
|
||||
for (auto const& vt : alpAccepted->getMap ())
|
||||
{
|
||||
m_journal.trace << "pubAccepted: " << vt.second->getJson ();
|
||||
pubValidatedTransaction (lpAccepted, *vt.second);
|
||||
@@ -2775,7 +2775,7 @@ void NetworkOPsImp::pubAccountTransaction (
|
||||
|
||||
std::string sObj = to_string (jvObj);
|
||||
|
||||
BOOST_FOREACH (InfoSub::ref isrListener, notify)
|
||||
for (InfoSub::ref isrListener : notify)
|
||||
{
|
||||
isrListener->send (jvObj, sObj, true);
|
||||
}
|
||||
@@ -2793,7 +2793,7 @@ void NetworkOPsImp::subAccount (InfoSub::ref isrListener,
|
||||
SubInfoMapType& subMap = rt ? mSubRTAccount : mSubAccount;
|
||||
|
||||
// For the connection, monitor each account.
|
||||
BOOST_FOREACH (const RippleAddress & naAccountID, vnaAccountIDs)
|
||||
for (auto const& naAccountID : vnaAccountIDs)
|
||||
{
|
||||
m_journal.trace << "subAccount:"
|
||||
" account: " << naAccountID.humanAccountID ();
|
||||
@@ -2803,7 +2803,7 @@ void NetworkOPsImp::subAccount (InfoSub::ref isrListener,
|
||||
|
||||
ScopedLockType sl (mLock);
|
||||
|
||||
BOOST_FOREACH (const RippleAddress & naAccountID, vnaAccountIDs)
|
||||
for (auto const& naAccountID : vnaAccountIDs)
|
||||
{
|
||||
auto simIterator = subMap.find (naAccountID.getAccountID ());
|
||||
if (simIterator == subMap.end ())
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include <ripple/app/main/Application.h>
|
||||
#include <ripple/core/JobQueue.h>
|
||||
#include <ripple/resource/Fees.h>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -77,7 +76,7 @@ void PathRequests::updateAll (Ledger::ref inLedger,
|
||||
|
||||
do
|
||||
{
|
||||
BOOST_FOREACH (PathRequest::wref wRequest, requests)
|
||||
for (auto& wRequest : requests)
|
||||
{
|
||||
if (shouldCancel())
|
||||
break;
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time_io.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
#include <fstream>
|
||||
@@ -75,6 +74,20 @@ namespace ripple {
|
||||
#define REFERRAL_VALIDATORS_MAX 50
|
||||
#define REFERRAL_IPS_MAX 50
|
||||
|
||||
template<class Iterator>
|
||||
std::string
|
||||
strJoin (Iterator first, Iterator last, std::string strSeperator)
|
||||
{
|
||||
std::ostringstream ossValues;
|
||||
|
||||
for (Iterator start = first; first != last; first++)
|
||||
{
|
||||
ossValues << str (boost::format ("%s%s") % (start == first ? "" : strSeperator) % *first);
|
||||
}
|
||||
|
||||
return ossValues.str ();
|
||||
}
|
||||
|
||||
// VFALCO TODO move all function definitions inlined into the class.
|
||||
class UniqueNodeListImp
|
||||
: public UniqueNodeList
|
||||
@@ -115,10 +128,6 @@ private:
|
||||
std::vector<int> viReferrals;
|
||||
};
|
||||
|
||||
typedef hash_map<std::string, int> strIndex;
|
||||
typedef std::pair<std::string, int> IPAndPortNumber;
|
||||
typedef hash_map<std::pair< std::string, int>, score> epScore;
|
||||
|
||||
public:
|
||||
explicit UniqueNodeListImp (Stoppable& parent)
|
||||
: UniqueNodeList (parent)
|
||||
@@ -705,7 +714,7 @@ private:
|
||||
void trustedLoad ()
|
||||
{
|
||||
boost::regex rNode ("\\`\\s*(\\S+)[\\s]*(.*)\\'");
|
||||
BOOST_FOREACH (std::string const& c, getConfig ().CLUSTER_NODES)
|
||||
for (auto const& c : getConfig ().CLUSTER_NODES)
|
||||
{
|
||||
boost::smatch match;
|
||||
|
||||
@@ -743,7 +752,7 @@ private:
|
||||
bool bDist = false;
|
||||
|
||||
// For each node, distribute roundSeed to roundScores.
|
||||
BOOST_FOREACH (scoreNode & sn, vsnNodes)
|
||||
for (auto& sn : vsnNodes)
|
||||
{
|
||||
int iEntries = sn.viReferrals.size ();
|
||||
|
||||
@@ -752,7 +761,8 @@ private:
|
||||
score iTotal = (iEntries + 1) * iEntries / 2;
|
||||
score iBase = sn.iRoundSeed * iEntries / iTotal;
|
||||
|
||||
// Distribute the current entires' seed score to validators prioritized by mention order.
|
||||
// Distribute the current entires' seed score to validators
|
||||
// prioritized by mention order.
|
||||
for (int i = 0; i != iEntries; i++)
|
||||
{
|
||||
score iPoints = iBase * (iEntries - i) / iEntries;
|
||||
@@ -765,7 +775,7 @@ private:
|
||||
if (ShouldLog (lsTRACE, UniqueNodeList))
|
||||
{
|
||||
WriteLog (lsTRACE, UniqueNodeList) << "midway: ";
|
||||
BOOST_FOREACH (scoreNode & sn, vsnNodes)
|
||||
for (auto& sn : vsnNodes)
|
||||
{
|
||||
WriteLog (lsTRACE, UniqueNodeList) << str (boost::format ("%s| %d, %d, %d: [%s]")
|
||||
% sn.strValidator
|
||||
@@ -778,7 +788,7 @@ private:
|
||||
|
||||
// Add roundScore to score.
|
||||
// Make roundScore new roundSeed.
|
||||
BOOST_FOREACH (scoreNode & sn, vsnNodes)
|
||||
for (auto& sn : vsnNodes)
|
||||
{
|
||||
if (!bDist && sn.iRoundScore)
|
||||
bDist = true;
|
||||
@@ -791,7 +801,7 @@ private:
|
||||
if (ShouldLog (lsTRACE, UniqueNodeList))
|
||||
{
|
||||
WriteLog (lsTRACE, UniqueNodeList) << "finish: ";
|
||||
BOOST_FOREACH (scoreNode & sn, vsnNodes)
|
||||
for (auto& sn : vsnNodes)
|
||||
{
|
||||
WriteLog (lsTRACE, UniqueNodeList) << str (boost::format ("%s| %d, %d, %d: [%s]")
|
||||
% sn.strValidator
|
||||
@@ -813,8 +823,8 @@ private:
|
||||
//
|
||||
void scoreCompute ()
|
||||
{
|
||||
strIndex umPulicIdx; // Map of public key to index.
|
||||
strIndex umDomainIdx; // Map of domain to index.
|
||||
hash_map<std::string, int> umPulicIdx; // Map of public key to index.
|
||||
hash_map<std::string, int> umDomainIdx; // Map of domain to index.
|
||||
std::vector<scoreNode> vsnNodes; // Index to scoring node.
|
||||
|
||||
auto db = getApp().getWalletDB ().getDB ();
|
||||
@@ -836,7 +846,7 @@ private:
|
||||
std::string strPublicKey = db->getStrBinary ("PublicKey");
|
||||
std::string strSource = db->getStrBinary ("Source");
|
||||
int iScore = iSourceScore (static_cast<ValidatorSource> (strSource[0]));
|
||||
strIndex::iterator siOld = umPulicIdx.find (strPublicKey);
|
||||
auto siOld = umPulicIdx.find (strPublicKey);
|
||||
|
||||
if (siOld == umPulicIdx.end ())
|
||||
{
|
||||
@@ -882,7 +892,7 @@ private:
|
||||
std::string strPublicKey = db->getStrBinary ("PublicKey");
|
||||
std::string strSource = db->getStrBinary ("Source");
|
||||
int iScore = iSourceScore (static_cast<ValidatorSource> (strSource[0]));
|
||||
strIndex::iterator siOld = umPulicIdx.find (strPublicKey);
|
||||
auto siOld = umPulicIdx.find (strPublicKey);
|
||||
|
||||
if (siOld == umPulicIdx.end ())
|
||||
{
|
||||
@@ -919,7 +929,7 @@ private:
|
||||
// For debugging, print out initial scores.
|
||||
if (ShouldLog (lsTRACE, UniqueNodeList))
|
||||
{
|
||||
BOOST_FOREACH (scoreNode & sn, vsnNodes)
|
||||
for (auto& sn : vsnNodes)
|
||||
{
|
||||
WriteLog (lsTRACE, UniqueNodeList) << str (boost::format ("%s| %d, %d, %d")
|
||||
% sn.strValidator
|
||||
@@ -947,14 +957,12 @@ private:
|
||||
std::string strReferral = db->getStrBinary ("Referral");
|
||||
int iReferral;
|
||||
|
||||
strIndex::iterator itEntry;
|
||||
|
||||
RippleAddress na;
|
||||
|
||||
if (na.setNodePublic (strReferral))
|
||||
{
|
||||
// Referring a public key.
|
||||
itEntry = umPulicIdx.find (strReferral);
|
||||
auto itEntry = umPulicIdx.find (strReferral);
|
||||
|
||||
if (itEntry == umPulicIdx.end ())
|
||||
{
|
||||
@@ -977,19 +985,14 @@ private:
|
||||
{
|
||||
iReferral = itEntry->second;
|
||||
}
|
||||
|
||||
// WriteLog (lsTRACE, UniqueNodeList) << str(boost::format("%s: Public=%s iReferral=%d") % strValidator % strReferral % iReferral);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// Referring a domain.
|
||||
itEntry = umDomainIdx.find (strReferral);
|
||||
auto itEntry = umDomainIdx.find (strReferral);
|
||||
iReferral = itEntry == umDomainIdx.end ()
|
||||
? -1 // We ignore domains we can't find entires for.
|
||||
: itEntry->second;
|
||||
|
||||
// WriteLog (lsTRACE, UniqueNodeList) << str(boost::format("%s: Domain=%s iReferral=%d") % strValidator % strReferral % iReferral);
|
||||
}
|
||||
|
||||
if (iReferral >= 0 && iNode != iReferral)
|
||||
@@ -1008,7 +1011,7 @@ private:
|
||||
if (ShouldLog (lsTRACE, UniqueNodeList))
|
||||
{
|
||||
WriteLog (lsTRACE, UniqueNodeList) << "Scored:";
|
||||
BOOST_FOREACH (scoreNode & sn, vsnNodes)
|
||||
for (auto& sn : vsnNodes)
|
||||
{
|
||||
WriteLog (lsTRACE, UniqueNodeList) << str (boost::format ("%s| %d, %d, %d: [%s]")
|
||||
% sn.strValidator
|
||||
@@ -1094,14 +1097,13 @@ private:
|
||||
|
||||
// For each validator, get each referral and add its score to ip's score.
|
||||
// map of pair<IP,Port> :: score
|
||||
epScore umScore;
|
||||
hash_map<std::pair<std::string, int>, score> umScore;
|
||||
|
||||
typedef hash_map<std::string, int>::value_type vcType;
|
||||
BOOST_FOREACH (vcType & vc, umValidators)
|
||||
for (auto& vc : umValidators)
|
||||
{
|
||||
std::string strValidator = vc.first;
|
||||
|
||||
strIndex::iterator itIndex = umPulicIdx.find (strValidator);
|
||||
auto itIndex = umPulicIdx.find (strValidator);
|
||||
|
||||
if (itIndex != umPulicIdx.end ())
|
||||
{
|
||||
@@ -1121,7 +1123,7 @@ private:
|
||||
|
||||
std::pair< std::string, int> ep = std::make_pair (db->getStrBinary ("IP"), iPort);
|
||||
|
||||
epScore::iterator itEp = umScore.find (ep);
|
||||
auto itEp = umScore.find (ep);
|
||||
|
||||
umScore[ep] = itEp == umScore.end () ? iPoints : itEp->second + iPoints;
|
||||
iEntry++;
|
||||
@@ -1590,7 +1592,7 @@ private:
|
||||
vstrValues.resize (std::min ((int) pmtVecStrIps->size (), REFERRAL_IPS_MAX));
|
||||
|
||||
int iValues = 0;
|
||||
BOOST_FOREACH (std::string const& strReferral, *pmtVecStrIps)
|
||||
for (auto const& strReferral : *pmtVecStrIps)
|
||||
{
|
||||
if (iValues == REFERRAL_VALIDATORS_MAX)
|
||||
break;
|
||||
@@ -1664,7 +1666,7 @@ private:
|
||||
|
||||
vstrValues.reserve (std::min ((int) pmtVecStrValidators->size (), REFERRAL_VALIDATORS_MAX));
|
||||
|
||||
BOOST_FOREACH (std::string const& strReferral, *pmtVecStrValidators)
|
||||
for (auto const& strReferral : *pmtVecStrValidators)
|
||||
{
|
||||
if (iValues == REFERRAL_VALIDATORS_MAX)
|
||||
break;
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <ripple/app/misc/NetworkOPs.h>
|
||||
#include <ripple/app/tx/TransactionAcquire.h>
|
||||
#include <ripple/overlay/Overlay.h>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace ripple {
|
||||
@@ -118,7 +117,7 @@ void TransactionAcquire::onTimer (bool progress, ScopedLockType& psl)
|
||||
|
||||
bool found = false;
|
||||
Overlay::PeerSequence peerList = getApp().overlay ().getActivePeers ();
|
||||
BOOST_FOREACH (Peer::ptr const& peer, peerList)
|
||||
for (auto const& peer : peerList)
|
||||
{
|
||||
if (peer->hasTxSet (getHash ()))
|
||||
{
|
||||
@@ -129,7 +128,7 @@ void TransactionAcquire::onTimer (bool progress, ScopedLockType& psl)
|
||||
|
||||
if (!found)
|
||||
{
|
||||
BOOST_FOREACH (Peer::ptr const& peer, peerList)
|
||||
for (auto const& peer : peerList)
|
||||
peerHas (peer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <ripple/json/to_string.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <cassert>
|
||||
|
||||
namespace ripple {
|
||||
@@ -35,8 +34,7 @@ namespace ripple {
|
||||
void TransactionEngine::txnWrite ()
|
||||
{
|
||||
// Write back the account states
|
||||
typedef std::map<uint256, LedgerEntrySetEntry>::value_type u256_LES_pair;
|
||||
BOOST_FOREACH (u256_LES_pair & it, mNodes)
|
||||
for (auto& it : mNodes)
|
||||
{
|
||||
SLE::ref sleEntry = it.second.mEntry;
|
||||
|
||||
@@ -51,7 +49,8 @@ void TransactionEngine::txnWrite ()
|
||||
|
||||
case taaCREATE:
|
||||
{
|
||||
WriteLog (lsDEBUG, TransactionEngine) << "applyTransaction: taaCREATE: " << sleEntry->getText ();
|
||||
WriteLog (lsDEBUG, TransactionEngine) <<
|
||||
"applyTransaction: taaCREATE: " << sleEntry->getText ();
|
||||
|
||||
if (mLedger->writeBack (lepCREATE, sleEntry) & lepERROR)
|
||||
assert (false);
|
||||
@@ -60,7 +59,8 @@ void TransactionEngine::txnWrite ()
|
||||
|
||||
case taaMODIFY:
|
||||
{
|
||||
WriteLog (lsDEBUG, TransactionEngine) << "applyTransaction: taaMODIFY: " << sleEntry->getText ();
|
||||
WriteLog (lsDEBUG, TransactionEngine) <<
|
||||
"applyTransaction: taaMODIFY: " << sleEntry->getText ();
|
||||
|
||||
if (mLedger->writeBack (lepNONE, sleEntry) & lepERROR)
|
||||
assert (false);
|
||||
@@ -69,7 +69,8 @@ void TransactionEngine::txnWrite ()
|
||||
|
||||
case taaDELETE:
|
||||
{
|
||||
WriteLog (lsDEBUG, TransactionEngine) << "applyTransaction: taaDELETE: " << sleEntry->getText ();
|
||||
WriteLog (lsDEBUG, TransactionEngine) <<
|
||||
"applyTransaction: taaDELETE: " << sleEntry->getText ();
|
||||
|
||||
if (!mLedger->peekAccountStateMap ()->delItem (it.first))
|
||||
assert (false);
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <ripple/json/to_string.h>
|
||||
#include <ripple/protocol/STAccount.h>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace ripple {
|
||||
@@ -51,10 +50,11 @@ TransactionMetaSet::TransactionMetaSet (uint256 const& txid, std::uint32_t ledge
|
||||
|
||||
bool TransactionMetaSet::isNodeAffected (uint256 const& node) const
|
||||
{
|
||||
BOOST_FOREACH (const STObject & it, mNodes)
|
||||
|
||||
if (it.getFieldH256 (sfLedgerIndex) == node)
|
||||
for (auto const& n : mNodes)
|
||||
{
|
||||
if (n.getFieldH256 (sfLedgerIndex) == node)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -63,12 +63,12 @@ void TransactionMetaSet::setAffectedNode (uint256 const& node, SField::ref type,
|
||||
std::uint16_t nodeType)
|
||||
{
|
||||
// make sure the node exists and force its type
|
||||
BOOST_FOREACH (STObject & it, mNodes)
|
||||
for (auto& n : mNodes)
|
||||
{
|
||||
if (it.getFieldH256 (sfLedgerIndex) == node)
|
||||
if (n.getFieldH256 (sfLedgerIndex) == node)
|
||||
{
|
||||
it.setFName (type);
|
||||
it.setFieldU16 (sfLedgerEntryType, nodeType);
|
||||
n.setFName (type);
|
||||
n.setFieldU16 (sfLedgerEntryType, nodeType);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -83,10 +83,11 @@ void TransactionMetaSet::setAffectedNode (uint256 const& node, SField::ref type,
|
||||
|
||||
static void addIfUnique (std::vector<RippleAddress>& vector, RippleAddress const& address)
|
||||
{
|
||||
BOOST_FOREACH (const RippleAddress & a, vector)
|
||||
|
||||
for (auto const& a : vector)
|
||||
{
|
||||
if (a == address)
|
||||
return;
|
||||
}
|
||||
|
||||
vector.push_back (address);
|
||||
}
|
||||
@@ -98,7 +99,7 @@ std::vector<RippleAddress> TransactionMetaSet::getAffectedAccounts ()
|
||||
|
||||
// This code should match the behavior of the JS method:
|
||||
// Meta#getAffectedAccounts
|
||||
BOOST_FOREACH (const STObject & it, mNodes)
|
||||
for (auto const& it : mNodes)
|
||||
{
|
||||
int index = it.getFieldIndex ((it.getFName () == sfCreatedNode) ? sfNewFields : sfFinalFields);
|
||||
|
||||
@@ -108,7 +109,7 @@ std::vector<RippleAddress> TransactionMetaSet::getAffectedAccounts ()
|
||||
|
||||
if (inner)
|
||||
{
|
||||
BOOST_FOREACH (const STBase & field, inner->peekData ())
|
||||
for (auto const& field : inner->peekData ())
|
||||
{
|
||||
const STAccount* sa = dynamic_cast<const STAccount*> (&field);
|
||||
|
||||
@@ -148,10 +149,10 @@ STObject& TransactionMetaSet::getAffectedNode (SLE::ref node, SField::ref type)
|
||||
{
|
||||
assert (&type);
|
||||
uint256 index = node->getIndex ();
|
||||
BOOST_FOREACH (STObject & it, mNodes)
|
||||
for (auto& n : mNodes)
|
||||
{
|
||||
if (it.getFieldH256 (sfLedgerIndex) == index)
|
||||
return it;
|
||||
if (n.getFieldH256 (sfLedgerIndex) == index)
|
||||
return n;
|
||||
}
|
||||
mNodes.push_back (STObject (type));
|
||||
STObject& obj = mNodes.back ();
|
||||
@@ -165,10 +166,10 @@ STObject& TransactionMetaSet::getAffectedNode (SLE::ref node, SField::ref type)
|
||||
|
||||
STObject& TransactionMetaSet::getAffectedNode (uint256 const& node)
|
||||
{
|
||||
BOOST_FOREACH (STObject & it, mNodes)
|
||||
for (auto& n : mNodes)
|
||||
{
|
||||
if (it.getFieldH256 (sfLedgerIndex) == node)
|
||||
return it;
|
||||
if (n.getFieldH256 (sfLedgerIndex) == node)
|
||||
return n;
|
||||
}
|
||||
assert (false);
|
||||
throw std::runtime_error ("Affected node not found");
|
||||
@@ -176,10 +177,11 @@ STObject& TransactionMetaSet::getAffectedNode (uint256 const& node)
|
||||
|
||||
const STObject& TransactionMetaSet::peekAffectedNode (uint256 const& node) const
|
||||
{
|
||||
BOOST_FOREACH (const STObject & it, mNodes)
|
||||
|
||||
if (it.getFieldH256 (sfLedgerIndex) == node)
|
||||
return it;
|
||||
for (auto const& n : mNodes)
|
||||
{
|
||||
if (n.getFieldH256 (sfLedgerIndex) == node)
|
||||
return n;
|
||||
}
|
||||
|
||||
throw std::runtime_error ("Affected node not found");
|
||||
}
|
||||
|
||||
@@ -32,21 +32,6 @@ namespace ripple {
|
||||
|
||||
extern std::string urlEncode (std::string const& strSrc);
|
||||
|
||||
// NIKB TODO remove this function - it's only used for some logging in the UNL
|
||||
// code which can be trivially rewritten.
|
||||
template<class Iterator>
|
||||
std::string strJoin (Iterator first, Iterator last, std::string strSeperator)
|
||||
{
|
||||
std::ostringstream ossValues;
|
||||
|
||||
for (Iterator start = first; first != last; first++)
|
||||
{
|
||||
ossValues << str (boost::format ("%s%s") % (start == first ? "" : strSeperator) % *first);
|
||||
}
|
||||
|
||||
return ossValues.str ();
|
||||
}
|
||||
|
||||
// NIKB TODO Remove the need for all these overloads. Move them out of here.
|
||||
inline const std::string strHex (std::string const& strSrc)
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ inline std::uint32_t max (std::uint32_t x, std::uint32_t y)
|
||||
|
||||
bool RangeSet::hasValue (std::uint32_t v) const
|
||||
{
|
||||
BOOST_FOREACH (const value_type & it, mRanges)
|
||||
for (auto const& it : mRanges)
|
||||
{
|
||||
if (contains (it, v))
|
||||
return true;
|
||||
@@ -62,7 +62,7 @@ std::uint32_t RangeSet::getFirst () const
|
||||
|
||||
std::uint32_t RangeSet::getNext (std::uint32_t v) const
|
||||
{
|
||||
BOOST_FOREACH (const value_type & it, mRanges)
|
||||
for (auto const& it : mRanges)
|
||||
{
|
||||
if (it.first > v)
|
||||
return it.first;
|
||||
@@ -190,7 +190,7 @@ void RangeSet::clearValue (std::uint32_t v)
|
||||
std::string RangeSet::toString () const
|
||||
{
|
||||
std::string ret;
|
||||
BOOST_FOREACH (value_type const & it, mRanges)
|
||||
for (auto const& it : mRanges)
|
||||
{
|
||||
if (!ret.empty ())
|
||||
ret += ",";
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <beast/module/core/text/LexicalCast.h>
|
||||
#include <beast/streams/debug_ostream.h>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
#include <fstream>
|
||||
@@ -79,7 +78,7 @@ parseIniFile (std::string const& strInput, const bool bTrim)
|
||||
secResult[strSection] = IniFileSections::mapped_type ();
|
||||
|
||||
// Parse each line.
|
||||
BOOST_FOREACH (std::string & strValue, vLines)
|
||||
for (auto& strValue : vLines)
|
||||
{
|
||||
if (strValue.empty () || strValue[0] == '#')
|
||||
{
|
||||
@@ -448,7 +447,7 @@ void Config::load ()
|
||||
{
|
||||
RPC_STARTUP = Json::arrayValue;
|
||||
|
||||
BOOST_FOREACH (std::string const& strJson, *smtTmp)
|
||||
for (auto const& strJson : *smtTmp)
|
||||
{
|
||||
Json::Reader jrReader;
|
||||
Json::Value jvCommand;
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <ripple/crypto/RFC1751.h>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/range/adaptor/copied.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
@@ -403,7 +402,7 @@ int RFC1751::etob (std::string& strData, std::vector<std::string> vsHuman)
|
||||
memset (b, 0, sizeof (b));
|
||||
|
||||
p = 0;
|
||||
BOOST_FOREACH (std::string & strWord, vsHuman)
|
||||
for (auto& strWord : vsHuman)
|
||||
{
|
||||
l = strWord.length ();
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include <beast/asio/placeholders.h>
|
||||
#include <beast/threads/Thread.h>
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <mutex>
|
||||
|
||||
namespace ripple {
|
||||
@@ -143,7 +142,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
BOOST_FOREACH (std::string const& it, servers)
|
||||
for (auto const& it : servers)
|
||||
addServer (it);
|
||||
queryAll ();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
class STAccount : public STBlob
|
||||
class STAccount final
|
||||
: public STBlob
|
||||
{
|
||||
public:
|
||||
STAccount (Blob const& v) : STBlob (v)
|
||||
@@ -51,11 +52,11 @@ public:
|
||||
return std::unique_ptr<STBase> (construct (sit, name));
|
||||
}
|
||||
|
||||
SerializedTypeID getSType () const
|
||||
SerializedTypeID getSType () const override
|
||||
{
|
||||
return STI_ACCOUNT;
|
||||
}
|
||||
std::string getText () const;
|
||||
std::string getText () const override;
|
||||
|
||||
RippleAddress getValueNCA () const;
|
||||
void setValueNCA (RippleAddress const& nca);
|
||||
@@ -79,11 +80,13 @@ public:
|
||||
|
||||
bool isValueH160 () const;
|
||||
|
||||
private:
|
||||
virtual STAccount* duplicate () const
|
||||
std::unique_ptr<STBase>
|
||||
duplicate () const override
|
||||
{
|
||||
return new STAccount (*this);
|
||||
return std::make_unique<STAccount>(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
static STAccount* construct (SerializerIterator&, SField::ref);
|
||||
};
|
||||
|
||||
|
||||
@@ -38,7 +38,8 @@ namespace ripple {
|
||||
// Wire form:
|
||||
// High 8 bits are (offset+142), legal range is, 80 to 22 inclusive
|
||||
// Low 56 bits are value, legal range is 10^15 to (10^16 - 1) inclusive
|
||||
class STAmount : public STBase
|
||||
class STAmount final
|
||||
: public STBase
|
||||
{
|
||||
public:
|
||||
typedef std::uint64_t mantissa_type;
|
||||
@@ -110,6 +111,9 @@ private:
|
||||
std::unique_ptr<STAmount>
|
||||
construct (SerializerIterator&, SField::ref name);
|
||||
|
||||
void
|
||||
setSNValue (std::int64_t);
|
||||
|
||||
public:
|
||||
static
|
||||
STAmount
|
||||
@@ -213,9 +217,6 @@ public:
|
||||
// VFALCO TODO Remove this, it is only called from the unit test
|
||||
void roundSelf();
|
||||
|
||||
void setNValue (std::uint64_t v);
|
||||
void setSNValue (std::int64_t);
|
||||
|
||||
void negate()
|
||||
{
|
||||
if (*this != zero)
|
||||
@@ -288,9 +289,11 @@ public:
|
||||
return (mValue == 0) && mIsNative;
|
||||
}
|
||||
|
||||
private:
|
||||
STAmount*
|
||||
duplicate() const override;
|
||||
std::unique_ptr<STBase>
|
||||
duplicate () const override
|
||||
{
|
||||
return std::make_unique<STAmount>(*this);
|
||||
}
|
||||
|
||||
void canonicalize();
|
||||
void set (std::int64_t v);
|
||||
|
||||
@@ -42,40 +42,45 @@ public:
|
||||
typedef vector::size_type size_type;
|
||||
|
||||
public:
|
||||
STArray ()
|
||||
{
|
||||
;
|
||||
}
|
||||
explicit STArray (int n)
|
||||
STArray () = default;
|
||||
|
||||
explicit
|
||||
STArray (int n)
|
||||
{
|
||||
value.reserve (n);
|
||||
}
|
||||
explicit STArray (SField::ref f) : STBase (f)
|
||||
{
|
||||
;
|
||||
}
|
||||
STArray (SField::ref f, int n) : STBase (f)
|
||||
|
||||
explicit
|
||||
STArray (SField::ref f)
|
||||
: STBase (f)
|
||||
{ }
|
||||
|
||||
STArray (SField::ref f, int n)
|
||||
: STBase (f)
|
||||
{
|
||||
value.reserve (n);
|
||||
}
|
||||
STArray (SField::ref f, const vector & v) : STBase (f), value (v)
|
||||
{
|
||||
;
|
||||
}
|
||||
explicit STArray (vector & v) : value (v)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
virtual ~STArray () { }
|
||||
STArray (SField::ref f, const vector& v)
|
||||
: STBase (f), value (v)
|
||||
{ }
|
||||
|
||||
static std::unique_ptr<STBase>
|
||||
explicit
|
||||
STArray (vector & v)
|
||||
: value (v)
|
||||
{ }
|
||||
|
||||
virtual ~STArray () = default;
|
||||
|
||||
static
|
||||
std::unique_ptr<STBase>
|
||||
deserialize (SerializerIterator & sit, SField::ref name);
|
||||
|
||||
const vector& getValue () const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
vector& getValue ()
|
||||
{
|
||||
return value;
|
||||
@@ -197,10 +202,10 @@ public:
|
||||
return value.empty ();
|
||||
}
|
||||
|
||||
private:
|
||||
virtual STArray* duplicate () const override
|
||||
std::unique_ptr<STBase>
|
||||
duplicate () const override
|
||||
{
|
||||
return new STArray (*this);
|
||||
return std::make_unique<STArray>(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <ripple/protocol/SField.h>
|
||||
#include <ripple/protocol/Serializer.h>
|
||||
#include <ostream>
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
#include <string>
|
||||
#include <typeinfo>
|
||||
|
||||
@@ -126,9 +127,6 @@ public:
|
||||
SField::ref
|
||||
getFName() const;
|
||||
|
||||
std::unique_ptr<STBase>
|
||||
clone() const;
|
||||
|
||||
void
|
||||
addFieldID (Serializer& s) const;
|
||||
|
||||
@@ -136,17 +134,15 @@ public:
|
||||
std::unique_ptr <STBase>
|
||||
deserialize (SField::ref name);
|
||||
|
||||
virtual
|
||||
std::unique_ptr<STBase>
|
||||
duplicate () const
|
||||
{
|
||||
return std::make_unique<STBase>(*fName);
|
||||
}
|
||||
|
||||
protected:
|
||||
SField::ptr fName;
|
||||
|
||||
private:
|
||||
// VFALCO TODO Return std::unique_ptr <STBase>
|
||||
virtual
|
||||
STBase*
|
||||
duplicate() const
|
||||
{
|
||||
return new STBase (*fName);
|
||||
}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -25,57 +25,71 @@
|
||||
namespace ripple {
|
||||
|
||||
template <std::size_t Bits>
|
||||
class STBitString : public STBase
|
||||
class STBitString final
|
||||
: public STBase
|
||||
{
|
||||
public:
|
||||
typedef base_uint<Bits> BitString;
|
||||
|
||||
STBitString () {}
|
||||
STBitString (SField::ref n) : STBase (n) {}
|
||||
STBitString (const BitString& v) : bitString_ (v) {}
|
||||
STBitString () = default;
|
||||
|
||||
STBitString (SField::ref n)
|
||||
: STBase (n)
|
||||
{ }
|
||||
|
||||
STBitString (const BitString& v)
|
||||
: bitString_ (v)
|
||||
{ }
|
||||
|
||||
STBitString (SField::ref n, const BitString& v)
|
||||
: STBase (n), bitString_ (v)
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
STBitString (SField::ref n, const char* v) : STBase (n)
|
||||
STBitString (SField::ref n, const char* v)
|
||||
: STBase (n)
|
||||
{
|
||||
bitString_.SetHex (v);
|
||||
}
|
||||
|
||||
STBitString (SField::ref n, std::string const& v) : STBase (n)
|
||||
STBitString (SField::ref n, std::string const& v)
|
||||
: STBase (n)
|
||||
{
|
||||
bitString_.SetHex (v);
|
||||
}
|
||||
|
||||
static std::unique_ptr<STBase> deserialize (
|
||||
SerializerIterator& sit, SField::ref name)
|
||||
static
|
||||
std::unique_ptr<STBase>
|
||||
deserialize (SerializerIterator& sit, SField::ref name)
|
||||
{
|
||||
return std::unique_ptr<STBase> (construct (sit, name));
|
||||
return std::make_unique<STBitString> (name, sit.getBitString<Bits> ());
|
||||
}
|
||||
|
||||
SerializedTypeID getSType () const;
|
||||
SerializedTypeID
|
||||
getSType () const override;
|
||||
|
||||
std::string getText () const
|
||||
std::string
|
||||
getText () const override
|
||||
{
|
||||
return to_string (bitString_);
|
||||
}
|
||||
|
||||
bool isEquivalent (const STBase& t) const
|
||||
bool
|
||||
isEquivalent (const STBase& t) const override
|
||||
{
|
||||
const STBitString* v = dynamic_cast<const STBitString*> (&t);
|
||||
return v && (bitString_ == v->bitString_);
|
||||
}
|
||||
|
||||
void add (Serializer& s) const
|
||||
void
|
||||
add (Serializer& s) const override
|
||||
{
|
||||
assert (fName->isBinary ());
|
||||
assert (fName->fieldType == getSType());
|
||||
s.addBitString<Bits> (bitString_);
|
||||
}
|
||||
|
||||
const BitString& getValue () const
|
||||
const BitString&
|
||||
getValue () const
|
||||
{
|
||||
return bitString_;
|
||||
}
|
||||
@@ -91,47 +105,50 @@ public:
|
||||
return bitString_;
|
||||
}
|
||||
|
||||
virtual bool isDefault () const
|
||||
bool
|
||||
isDefault () const override
|
||||
{
|
||||
return bitString_ == zero;
|
||||
}
|
||||
|
||||
std::unique_ptr<STBase>
|
||||
duplicate () const override
|
||||
{
|
||||
return std::make_unique<STBitString>(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
BitString bitString_;
|
||||
|
||||
STBitString* duplicate () const
|
||||
{
|
||||
return new STBitString (*this);
|
||||
}
|
||||
|
||||
static STBitString* construct (SerializerIterator& u, SField::ref name)
|
||||
{
|
||||
return new STBitString (name, u.getBitString<Bits> ());
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
inline SerializedTypeID STBitString<128>::getSType () const
|
||||
{
|
||||
return STI_HASH128;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline SerializedTypeID STBitString<160>::getSType () const
|
||||
{
|
||||
return STI_HASH160;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline SerializedTypeID STBitString<256>::getSType () const
|
||||
{
|
||||
return STI_HASH256;
|
||||
}
|
||||
|
||||
using STHash128 = STBitString<128>;
|
||||
using STHash160 = STBitString<160>;
|
||||
using STHash256 = STBitString<256>;
|
||||
|
||||
template <>
|
||||
inline
|
||||
SerializedTypeID
|
||||
STHash128::getSType () const
|
||||
{
|
||||
return STI_HASH128;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline
|
||||
SerializedTypeID
|
||||
STHash160::getSType () const
|
||||
{
|
||||
return STI_HASH160;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline
|
||||
SerializedTypeID
|
||||
STHash256::getSType () const
|
||||
{
|
||||
return STI_HASH256;
|
||||
}
|
||||
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
|
||||
@@ -26,37 +26,44 @@
|
||||
namespace ripple {
|
||||
|
||||
// variable length byte string
|
||||
class STBlob : public STBase
|
||||
class STBlob
|
||||
: public STBase
|
||||
{
|
||||
public:
|
||||
STBlob (Blob const& v) : value (v)
|
||||
{
|
||||
;
|
||||
}
|
||||
STBlob (SField::ref n, Blob const& v) : STBase (n), value (v)
|
||||
{
|
||||
;
|
||||
}
|
||||
STBlob (SField::ref n) : STBase (n)
|
||||
{
|
||||
;
|
||||
}
|
||||
STBlob () = default;
|
||||
|
||||
STBlob (Blob const& v)
|
||||
: value (v)
|
||||
{ }
|
||||
|
||||
STBlob (SField::ref n, Blob const& v)
|
||||
: STBase (n), value (v)
|
||||
{ }
|
||||
|
||||
STBlob (SField::ref n)
|
||||
: STBase (n)
|
||||
{ }
|
||||
|
||||
STBlob (SerializerIterator&, SField::ref name = sfGeneric);
|
||||
STBlob ()
|
||||
|
||||
static
|
||||
std::unique_ptr<STBase>
|
||||
deserialize (SerializerIterator& sit, SField::ref name)
|
||||
{
|
||||
;
|
||||
}
|
||||
static std::unique_ptr<STBase> deserialize (SerializerIterator& sit, SField::ref name)
|
||||
{
|
||||
return std::unique_ptr<STBase> (construct (sit, name));
|
||||
return std::make_unique<STBlob> (name, sit.getVL ());
|
||||
}
|
||||
|
||||
virtual SerializedTypeID getSType () const
|
||||
SerializedTypeID
|
||||
getSType () const override
|
||||
{
|
||||
return STI_VL;
|
||||
}
|
||||
virtual std::string getText () const;
|
||||
void add (Serializer& s) const
|
||||
|
||||
std::string
|
||||
getText () const override;
|
||||
|
||||
void
|
||||
add (Serializer& s) const override
|
||||
{
|
||||
assert (fName->isBinary ());
|
||||
assert ((fName->fieldType == STI_VL) ||
|
||||
@@ -64,41 +71,53 @@ public:
|
||||
s.addVL (value);
|
||||
}
|
||||
|
||||
Blob const& peekValue () const
|
||||
Blob const&
|
||||
peekValue () const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
Blob& peekValue ()
|
||||
|
||||
Blob&
|
||||
peekValue ()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
Blob getValue () const
|
||||
|
||||
Blob
|
||||
getValue () const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
void setValue (Blob const& v)
|
||||
|
||||
void
|
||||
setValue (Blob const& v)
|
||||
{
|
||||
value = v;
|
||||
}
|
||||
|
||||
explicit
|
||||
operator Blob () const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
virtual bool isEquivalent (const STBase& t) const;
|
||||
virtual bool isDefault () const
|
||||
|
||||
bool
|
||||
isEquivalent (const STBase& t) const override;
|
||||
|
||||
bool
|
||||
isDefault () const override
|
||||
{
|
||||
return value.empty ();
|
||||
}
|
||||
|
||||
std::unique_ptr<STBase>
|
||||
duplicate () const override
|
||||
{
|
||||
return std::make_unique<STBlob>(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
Blob value;
|
||||
|
||||
virtual STBlob* duplicate () const
|
||||
{
|
||||
return new STBlob (*this);
|
||||
}
|
||||
static STBlob* construct (SerializerIterator&, SField::ref);
|
||||
};
|
||||
|
||||
} // ripple
|
||||
|
||||
@@ -25,70 +25,79 @@
|
||||
namespace ripple {
|
||||
|
||||
template <typename Integer>
|
||||
class STInteger : public STBase
|
||||
class STInteger
|
||||
: public STBase
|
||||
{
|
||||
public:
|
||||
explicit STInteger (Integer v) : value_ (v)
|
||||
{
|
||||
}
|
||||
explicit
|
||||
STInteger (Integer v)
|
||||
: value_ (v)
|
||||
{ }
|
||||
|
||||
STInteger (SField::ref n, Integer v = 0) : STBase (n), value_ (v)
|
||||
{
|
||||
}
|
||||
STInteger (SField::ref n, Integer v = 0)
|
||||
: STBase (n), value_ (v)
|
||||
{ }
|
||||
|
||||
static std::unique_ptr<STBase> deserialize (
|
||||
SerializerIterator& sit, SField::ref name)
|
||||
{
|
||||
return std::unique_ptr<STBase> (construct (sit, name));
|
||||
}
|
||||
static
|
||||
std::unique_ptr<STBase>
|
||||
deserialize (SerializerIterator& sit, SField::ref name);
|
||||
|
||||
SerializedTypeID getSType () const
|
||||
{
|
||||
return STI_UINT8;
|
||||
}
|
||||
SerializedTypeID
|
||||
getSType () const override;
|
||||
|
||||
Json::Value getJson (int) const;
|
||||
std::string getText () const;
|
||||
Json::Value
|
||||
getJson (int) const override;
|
||||
|
||||
void add (Serializer& s) const
|
||||
std::string
|
||||
getText () const override;
|
||||
|
||||
void
|
||||
add (Serializer& s) const override
|
||||
{
|
||||
assert (fName->isBinary ());
|
||||
assert (fName->fieldType == getSType ());
|
||||
s.addInteger (value_);
|
||||
}
|
||||
|
||||
Integer getValue () const
|
||||
Integer
|
||||
getValue () const
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
void setValue (Integer v)
|
||||
|
||||
void
|
||||
setValue (Integer v)
|
||||
{
|
||||
value_ = v;
|
||||
}
|
||||
|
||||
operator Integer () const
|
||||
operator
|
||||
Integer () const
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
virtual bool isDefault () const
|
||||
|
||||
virtual
|
||||
bool isDefault () const override
|
||||
{
|
||||
return value_ == 0;
|
||||
}
|
||||
|
||||
bool isEquivalent (const STBase& t) const
|
||||
bool
|
||||
isEquivalent (const STBase& t) const override
|
||||
{
|
||||
const STInteger* v = dynamic_cast<const STInteger*> (&t);
|
||||
return v && (value_ == v->value_);
|
||||
}
|
||||
|
||||
std::unique_ptr<STBase>
|
||||
duplicate () const override
|
||||
{
|
||||
return std::make_unique<STInteger>(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
Integer value_;
|
||||
|
||||
STInteger* duplicate () const
|
||||
{
|
||||
return new STInteger (*this);
|
||||
}
|
||||
static STInteger* construct (SerializerIterator&, SField::ref f);
|
||||
};
|
||||
|
||||
using STUInt8 = STInteger<unsigned char>;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
class STLedgerEntry
|
||||
class STLedgerEntry final
|
||||
: public STObject
|
||||
, public CountedObject <STLedgerEntry>
|
||||
{
|
||||
@@ -41,13 +41,13 @@ public:
|
||||
STLedgerEntry (LedgerEntryType type, uint256 const& index);
|
||||
STLedgerEntry (const STObject & object, uint256 const& index);
|
||||
|
||||
SerializedTypeID getSType () const
|
||||
SerializedTypeID getSType () const override
|
||||
{
|
||||
return STI_LEDGERENTRY;
|
||||
}
|
||||
std::string getFullText () const;
|
||||
std::string getText () const;
|
||||
Json::Value getJson (int options) const;
|
||||
std::string getFullText () const override;
|
||||
std::string getText () const override;
|
||||
Json::Value getJson (int options) const override;
|
||||
|
||||
uint256 const& getIndex () const
|
||||
{
|
||||
@@ -94,12 +94,13 @@ public:
|
||||
std::uint32_t & prevLedgerID);
|
||||
std::vector<uint256> getOwners (); // nodes notified if this node is deleted
|
||||
|
||||
private:
|
||||
STLedgerEntry* duplicate () const
|
||||
std::unique_ptr<STBase>
|
||||
duplicate () const override
|
||||
{
|
||||
return new STLedgerEntry (*this);
|
||||
return std::make_unique<STLedgerEntry>(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
/** Make STObject comply with the template for this SLE type
|
||||
Can throw
|
||||
*/
|
||||
|
||||
@@ -125,7 +125,7 @@ public:
|
||||
|
||||
int addObject (const STBase & t)
|
||||
{
|
||||
mData.push_back (t.clone ().release ());
|
||||
mData.push_back (t.duplicate ().release ());
|
||||
return mData.size () - 1;
|
||||
}
|
||||
int giveObject (std::unique_ptr<STBase> t)
|
||||
@@ -317,12 +317,13 @@ public:
|
||||
return ! (*this == o);
|
||||
}
|
||||
|
||||
private:
|
||||
virtual STObject* duplicate () const override
|
||||
std::unique_ptr<STBase>
|
||||
duplicate () const override
|
||||
{
|
||||
return new STObject (*this);
|
||||
return std::make_unique<STObject>(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
// Implementation for getting (most) fields that return by value.
|
||||
//
|
||||
// The remove_cv and remove_reference are necessitated by the STBitString
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
// VFALCO Why isn't this derived from STBase?
|
||||
class STPathElement
|
||||
{
|
||||
public:
|
||||
@@ -82,35 +81,46 @@ public:
|
||||
hash_value_ = get_hash (*this);
|
||||
}
|
||||
|
||||
int getNodeType () const
|
||||
int
|
||||
getNodeType () const
|
||||
{
|
||||
return mType;
|
||||
}
|
||||
bool isOffer () const
|
||||
|
||||
bool
|
||||
isOffer () const
|
||||
{
|
||||
return is_offer_;
|
||||
}
|
||||
bool isAccount () const
|
||||
|
||||
bool
|
||||
isAccount () const
|
||||
{
|
||||
return !isOffer ();
|
||||
}
|
||||
|
||||
// Nodes are either an account ID or a offer prefix. Offer prefixs denote a
|
||||
// class of offers.
|
||||
Account const& getAccountID () const
|
||||
Account const&
|
||||
getAccountID () const
|
||||
{
|
||||
return mAccountID;
|
||||
}
|
||||
Currency const& getCurrency () const
|
||||
|
||||
Currency const&
|
||||
getCurrency () const
|
||||
{
|
||||
return mCurrencyID;
|
||||
}
|
||||
Account const& getIssuerID () const
|
||||
|
||||
Account const&
|
||||
getIssuerID () const
|
||||
{
|
||||
return mIssuerID;
|
||||
}
|
||||
|
||||
bool operator== (const STPathElement& t) const
|
||||
bool
|
||||
operator== (const STPathElement& t) const
|
||||
{
|
||||
return (mType & typeAccount) == (t.mType & typeAccount) &&
|
||||
hash_value_ == t.hash_value_ &&
|
||||
@@ -162,9 +172,13 @@ public:
|
||||
mPath.emplace_back (std::forward<Args> (args)...);
|
||||
}
|
||||
|
||||
bool hasSeen (Account const& account, Currency const& currency,
|
||||
bool
|
||||
hasSeen (
|
||||
Account const& account, Currency const& currency,
|
||||
Account const& issuer) const;
|
||||
Json::Value getJson (int) const;
|
||||
|
||||
Json::Value
|
||||
getJson (int) const;
|
||||
|
||||
std::vector<STPathElement>::const_iterator
|
||||
begin () const
|
||||
@@ -178,7 +192,8 @@ public:
|
||||
return mPath.end ();
|
||||
}
|
||||
|
||||
bool operator== (STPath const& t) const
|
||||
bool
|
||||
operator== (STPath const& t) const
|
||||
{
|
||||
return mPath == t.mPath;
|
||||
}
|
||||
@@ -212,7 +227,8 @@ private:
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// A set of zero or more payment paths
|
||||
class STPathSet : public STBase
|
||||
class STPathSet final
|
||||
: public STBase
|
||||
{
|
||||
public:
|
||||
STPathSet () = default;
|
||||
@@ -223,91 +239,77 @@ public:
|
||||
|
||||
static
|
||||
std::unique_ptr<STBase>
|
||||
deserialize (SerializerIterator& sit, SField::ref name)
|
||||
deserialize (SerializerIterator& sit, SField::ref name);
|
||||
|
||||
std::unique_ptr<STBase>
|
||||
duplicate () const override
|
||||
{
|
||||
return std::unique_ptr<STBase> (construct (sit, name));
|
||||
return std::make_unique<STPathSet>(*this);
|
||||
}
|
||||
|
||||
void add (Serializer& s) const;
|
||||
virtual Json::Value getJson (int) const;
|
||||
void
|
||||
add (Serializer& s) const override;
|
||||
|
||||
SerializedTypeID getSType () const
|
||||
Json::Value
|
||||
getJson (int) const override;
|
||||
|
||||
SerializedTypeID
|
||||
getSType () const override
|
||||
{
|
||||
return STI_PATHSET;
|
||||
}
|
||||
std::vector<STPath>::size_type
|
||||
size () const
|
||||
{
|
||||
return value.size ();
|
||||
}
|
||||
|
||||
bool empty () const
|
||||
{
|
||||
return value.empty ();
|
||||
}
|
||||
|
||||
void push_back (STPath const& e)
|
||||
{
|
||||
value.push_back (e);
|
||||
}
|
||||
|
||||
bool assembleAdd(STPath const& base, STPathElement const& tail)
|
||||
{ // assemble base+tail and add it to the set if it's not a duplicate
|
||||
value.push_back (base);
|
||||
|
||||
std::vector<STPath>::reverse_iterator it = value.rbegin ();
|
||||
|
||||
STPath& newPath = *it;
|
||||
newPath.push_back (tail);
|
||||
|
||||
while (++it != value.rend ())
|
||||
{
|
||||
if (*it == newPath)
|
||||
{
|
||||
value.pop_back ();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool isEquivalent (const STBase& t) const;
|
||||
virtual bool isDefault () const
|
||||
bool
|
||||
assembleAdd(STPath const& base, STPathElement const& tail);
|
||||
|
||||
bool
|
||||
isEquivalent (const STBase& t) const override;
|
||||
|
||||
bool
|
||||
isDefault () const override
|
||||
{
|
||||
return value.empty ();
|
||||
}
|
||||
|
||||
// std::vector like interface:
|
||||
std::vector<STPath>::const_reference
|
||||
operator[] (std::vector<STPath>::size_type n) const
|
||||
{
|
||||
return value[n];
|
||||
}
|
||||
|
||||
std::vector<STPath>::const_iterator begin () const
|
||||
std::vector<STPath>::const_iterator
|
||||
begin () const
|
||||
{
|
||||
return value.begin ();
|
||||
}
|
||||
|
||||
std::vector<STPath>::const_iterator end () const
|
||||
std::vector<STPath>::const_iterator
|
||||
end () const
|
||||
{
|
||||
return value.end ();
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<STPath> value;
|
||||
|
||||
STPathSet (SField::ref n, const std::vector<STPath>& v)
|
||||
: STBase (n), value (v)
|
||||
{ }
|
||||
|
||||
STPathSet* duplicate () const
|
||||
std::vector<STPath>::size_type
|
||||
size () const
|
||||
{
|
||||
return new STPathSet (*this);
|
||||
return value.size ();
|
||||
}
|
||||
|
||||
static
|
||||
STPathSet*
|
||||
construct (SerializerIterator&, SField::ref);
|
||||
bool
|
||||
empty () const
|
||||
{
|
||||
return value.empty ();
|
||||
}
|
||||
|
||||
void
|
||||
push_back (STPath const& e)
|
||||
{
|
||||
value.push_back (e);
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<STPath> value;
|
||||
};
|
||||
|
||||
} // ripple
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace ripple {
|
||||
#define TXN_SQL_INCLUDED 'I'
|
||||
#define TXN_SQL_UNKNOWN 'U'
|
||||
|
||||
class STTx
|
||||
class STTx final
|
||||
: public STObject
|
||||
, public CountedObject <STTx>
|
||||
{
|
||||
@@ -57,11 +57,11 @@ public:
|
||||
explicit STTx (STObject const& object);
|
||||
|
||||
// STObject functions
|
||||
SerializedTypeID getSType () const
|
||||
SerializedTypeID getSType () const override
|
||||
{
|
||||
return STI_TRANSACTION;
|
||||
}
|
||||
std::string getFullText () const;
|
||||
std::string getFullText () const override;
|
||||
|
||||
// outer transaction functions / signature functions
|
||||
Blob getSignature () const;
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
|
||||
uint256 getTransactionID () const;
|
||||
|
||||
virtual Json::Value getJson (int options) const;
|
||||
virtual Json::Value getJson (int options) const override;
|
||||
virtual Json::Value getJson (int options, bool binary) const;
|
||||
|
||||
void sign (RippleAddress const& private_key);
|
||||
@@ -143,12 +143,13 @@ public:
|
||||
char status,
|
||||
std::string const& escapedMetaData) const;
|
||||
|
||||
private:
|
||||
STTx* duplicate () const override
|
||||
std::unique_ptr<STBase>
|
||||
duplicate () const override
|
||||
{
|
||||
return new STTx (*this);
|
||||
return std::make_unique<STTx>(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
TxType tx_type_;
|
||||
|
||||
mutable boost::tribool sig_state_;
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace ripple {
|
||||
// Validation flags
|
||||
const std::uint32_t vfFullyCanonicalSig = 0x80000000; // signature is fully canonical
|
||||
|
||||
class STValidation
|
||||
class STValidation final
|
||||
: public STObject
|
||||
, public CountedObject <STValidation>
|
||||
{
|
||||
|
||||
@@ -27,100 +27,139 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
class STVector256 : public STBase
|
||||
class STVector256 final
|
||||
: public STBase
|
||||
{
|
||||
public:
|
||||
STVector256 () = default;
|
||||
|
||||
explicit STVector256 (SField::ref n)
|
||||
: STBase (n)
|
||||
{ }
|
||||
|
||||
explicit STVector256 (std::vector<uint256> const& vector)
|
||||
: mValue (vector)
|
||||
{ }
|
||||
|
||||
SerializedTypeID getSType () const
|
||||
SerializedTypeID
|
||||
getSType () const override
|
||||
{
|
||||
return STI_VECTOR256;
|
||||
}
|
||||
void add (Serializer& s) const;
|
||||
|
||||
void
|
||||
add (Serializer& s) const override;
|
||||
|
||||
static
|
||||
std::unique_ptr<STBase>
|
||||
deserialize (SerializerIterator& sit, SField::ref name)
|
||||
{
|
||||
return std::unique_ptr<STBase> (construct (sit, name));
|
||||
}
|
||||
deserialize (SerializerIterator& sit, SField::ref name);
|
||||
|
||||
const std::vector<uint256>&
|
||||
peekValue () const
|
||||
{
|
||||
return mValue;
|
||||
}
|
||||
Json::Value
|
||||
getJson (int) const override;
|
||||
|
||||
std::vector<uint256>&
|
||||
peekValue ()
|
||||
{
|
||||
return mValue;
|
||||
}
|
||||
bool
|
||||
isEquivalent (const STBase& t) const override;
|
||||
|
||||
virtual bool isEquivalent (const STBase& t) const;
|
||||
virtual bool isDefault () const
|
||||
bool
|
||||
isDefault () const override
|
||||
{
|
||||
return mValue.empty ();
|
||||
}
|
||||
|
||||
void
|
||||
setValue (const STVector256& v)
|
||||
{
|
||||
mValue = v.mValue;
|
||||
}
|
||||
|
||||
std::unique_ptr<STBase>
|
||||
duplicate () const override
|
||||
{
|
||||
return std::make_unique<STVector256>(*this);
|
||||
}
|
||||
|
||||
/** Retrieve a copy of the vector we contain */
|
||||
explicit
|
||||
operator std::vector<uint256> () const
|
||||
{
|
||||
return mValue;
|
||||
}
|
||||
|
||||
// std::vector<uint256> interface:
|
||||
std::vector<uint256>::size_type
|
||||
size () const
|
||||
{
|
||||
return mValue.size ();
|
||||
}
|
||||
bool empty () const
|
||||
|
||||
void
|
||||
resize (std::vector<uint256>::size_type n)
|
||||
{
|
||||
return mValue.resize (n);
|
||||
}
|
||||
|
||||
bool
|
||||
empty () const
|
||||
{
|
||||
return mValue.empty ();
|
||||
}
|
||||
|
||||
std::vector<uint256>::reference
|
||||
operator[] (std::vector<uint256>::size_type n)
|
||||
{
|
||||
return mValue[n];
|
||||
}
|
||||
|
||||
std::vector<uint256>::const_reference
|
||||
operator[] (std::vector<uint256>::size_type n) const
|
||||
{
|
||||
return mValue[n];
|
||||
}
|
||||
|
||||
void setValue (const STVector256& v)
|
||||
{
|
||||
mValue = v.mValue;
|
||||
}
|
||||
|
||||
void push_back (uint256 const& v)
|
||||
void
|
||||
push_back (uint256 const& v)
|
||||
{
|
||||
mValue.push_back (v);
|
||||
}
|
||||
|
||||
void sort ()
|
||||
std::vector<uint256>::iterator
|
||||
begin()
|
||||
{
|
||||
std::sort (mValue.begin (), mValue.end ());
|
||||
return mValue.begin ();
|
||||
}
|
||||
|
||||
Json::Value getJson (int) const;
|
||||
|
||||
std::vector<uint256>::const_iterator
|
||||
begin() const
|
||||
{
|
||||
return mValue.begin ();
|
||||
}
|
||||
|
||||
std::vector<uint256>::iterator
|
||||
end()
|
||||
{
|
||||
return mValue.end ();
|
||||
}
|
||||
|
||||
std::vector<uint256>::const_iterator
|
||||
end() const
|
||||
{
|
||||
return mValue.end ();
|
||||
}
|
||||
|
||||
std::vector<uint256>::iterator
|
||||
erase (std::vector<uint256>::iterator position)
|
||||
{
|
||||
return mValue.erase (position);
|
||||
}
|
||||
|
||||
void
|
||||
clear () noexcept
|
||||
{
|
||||
return mValue.clear ();
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<uint256> mValue;
|
||||
|
||||
STVector256* duplicate () const
|
||||
{
|
||||
return new STVector256 (*this);
|
||||
}
|
||||
static STVector256* construct (SerializerIterator&, SField::ref);
|
||||
};
|
||||
|
||||
} // ripple
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <beast/cxx14/iterator.h> // <iterator>
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
#include <iostream>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -35,6 +37,9 @@ static const std::uint64_t tenTo14 = 100000000000000ull;
|
||||
static const std::uint64_t tenTo14m1 = tenTo14 - 1;
|
||||
static const std::uint64_t tenTo17 = tenTo14 * 1000;
|
||||
|
||||
STAmount const saZero (noIssue(), 0u);
|
||||
STAmount const saOne (noIssue(), 1u);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
STAmount::STAmount (SField::ref name, Issue const& issue,
|
||||
@@ -494,14 +499,6 @@ std::string STAmount::getHumanCurrency () const
|
||||
return to_string (mIssue.currency);
|
||||
}
|
||||
|
||||
void
|
||||
STAmount::setNValue (std::uint64_t v)
|
||||
{
|
||||
if (!mIsNative)
|
||||
throw std::runtime_error ("not native");
|
||||
mValue = v;
|
||||
}
|
||||
|
||||
void
|
||||
STAmount::setSNValue (std::int64_t v)
|
||||
{
|
||||
@@ -752,12 +749,6 @@ STAmount::isEquivalent (const STBase& t) const
|
||||
return v && (*v == *this);
|
||||
}
|
||||
|
||||
STAmount*
|
||||
STAmount::duplicate () const
|
||||
{
|
||||
return new STAmount (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// amount = value * [10 ^ offset]
|
||||
|
||||
@@ -138,12 +138,6 @@ STBase::getFName() const
|
||||
return *fName;
|
||||
}
|
||||
|
||||
std::unique_ptr<STBase>
|
||||
STBase::clone() const
|
||||
{
|
||||
return std::unique_ptr<STBase> (duplicate());
|
||||
}
|
||||
|
||||
void
|
||||
STBase::addFieldID (Serializer& s) const
|
||||
{
|
||||
@@ -162,7 +156,7 @@ STBase::deserialize (SField::ref name)
|
||||
STBase*
|
||||
new_clone (const STBase& s)
|
||||
{
|
||||
STBase* const copy (s.clone ().release ());
|
||||
STBase* const copy (s.duplicate ().release ());
|
||||
assert (typeid (*copy) == typeid (s));
|
||||
return copy;
|
||||
}
|
||||
|
||||
@@ -29,17 +29,14 @@ STBlob::STBlob (SerializerIterator& st, SField::ref name)
|
||||
value = st.getVL ();
|
||||
}
|
||||
|
||||
std::string STBlob::getText () const
|
||||
std::string
|
||||
STBlob::getText () const
|
||||
{
|
||||
return strHex (value);
|
||||
}
|
||||
|
||||
STBlob* STBlob::construct (SerializerIterator& u, SField::ref name)
|
||||
{
|
||||
return new STBlob (name, u.getVL ());
|
||||
}
|
||||
|
||||
bool STBlob::isEquivalent (const STBase& t) const
|
||||
bool
|
||||
STBlob::isEquivalent (const STBase& t) const
|
||||
{
|
||||
const STBlob* v = dynamic_cast<const STBlob*> (&t);
|
||||
return v && (value == v->value);
|
||||
|
||||
@@ -29,19 +29,22 @@
|
||||
namespace ripple {
|
||||
|
||||
template <>
|
||||
SerializedTypeID STUInt8::getSType () const
|
||||
SerializedTypeID
|
||||
STUInt8::getSType () const
|
||||
{
|
||||
return STI_UINT8;
|
||||
}
|
||||
|
||||
template <>
|
||||
STUInt8* STUInt8::construct (SerializerIterator& u, SField::ref name)
|
||||
std::unique_ptr<STBase>
|
||||
STUInt8::deserialize (SerializerIterator& sit, SField::ref name)
|
||||
{
|
||||
return new STUInt8 (name, u.get8 ());
|
||||
return std::make_unique <STUInt8> (name, sit.get8 ());
|
||||
}
|
||||
|
||||
template <>
|
||||
std::string STUInt8::getText () const
|
||||
std::string
|
||||
STUInt8::getText () const
|
||||
{
|
||||
if (getFName () == sfTransactionResult)
|
||||
{
|
||||
@@ -55,7 +58,8 @@ std::string STUInt8::getText () const
|
||||
}
|
||||
|
||||
template <>
|
||||
Json::Value STUInt8::getJson (int) const
|
||||
Json::Value
|
||||
STUInt8::getJson (int) const
|
||||
{
|
||||
if (getFName () == sfTransactionResult)
|
||||
{
|
||||
@@ -74,19 +78,22 @@ Json::Value STUInt8::getJson (int) const
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template <>
|
||||
SerializedTypeID STUInt16::getSType () const
|
||||
SerializedTypeID
|
||||
STUInt16::getSType () const
|
||||
{
|
||||
return STI_UINT16;
|
||||
}
|
||||
|
||||
template <>
|
||||
STUInt16* STUInt16::construct (SerializerIterator& u, SField::ref name)
|
||||
std::unique_ptr<STBase>
|
||||
STUInt16::deserialize (SerializerIterator& sit, SField::ref name)
|
||||
{
|
||||
return new STUInt16 (name, u.get16 ());
|
||||
return std::make_unique <STUInt16> (name, sit.get16 ());
|
||||
}
|
||||
|
||||
template <>
|
||||
std::string STUInt16::getText () const
|
||||
std::string
|
||||
STUInt16::getText () const
|
||||
{
|
||||
if (getFName () == sfLedgerEntryType)
|
||||
{
|
||||
@@ -99,8 +106,8 @@ std::string STUInt16::getText () const
|
||||
|
||||
if (getFName () == sfTransactionType)
|
||||
{
|
||||
TxFormats::Item const* const item =
|
||||
TxFormats::getInstance().findByType (static_cast <TxType> (value_));
|
||||
auto item =TxFormats::getInstance().findByType (
|
||||
static_cast <TxType> (value_));
|
||||
|
||||
if (item != nullptr)
|
||||
return item->getName ();
|
||||
@@ -110,12 +117,13 @@ std::string STUInt16::getText () const
|
||||
}
|
||||
|
||||
template <>
|
||||
Json::Value STUInt16::getJson (int) const
|
||||
Json::Value
|
||||
STUInt16::getJson (int) const
|
||||
{
|
||||
if (getFName () == sfLedgerEntryType)
|
||||
{
|
||||
LedgerFormats::Item const* const item =
|
||||
LedgerFormats::getInstance ().findByType (static_cast <LedgerEntryType> (value_));
|
||||
auto item = LedgerFormats::getInstance ().findByType (
|
||||
static_cast <LedgerEntryType> (value_));
|
||||
|
||||
if (item != nullptr)
|
||||
return item->getName ();
|
||||
@@ -123,8 +131,8 @@ Json::Value STUInt16::getJson (int) const
|
||||
|
||||
if (getFName () == sfTransactionType)
|
||||
{
|
||||
TxFormats::Item const* const item =
|
||||
TxFormats::getInstance().findByType (static_cast <TxType> (value_));
|
||||
auto item = TxFormats::getInstance().findByType (
|
||||
static_cast <TxType> (value_));
|
||||
|
||||
if (item != nullptr)
|
||||
return item->getName ();
|
||||
@@ -136,49 +144,59 @@ Json::Value STUInt16::getJson (int) const
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template <>
|
||||
SerializedTypeID STUInt32::getSType () const
|
||||
SerializedTypeID
|
||||
STUInt32::getSType () const
|
||||
{
|
||||
return STI_UINT32;
|
||||
}
|
||||
|
||||
template <>
|
||||
STUInt32* STUInt32::construct (SerializerIterator& u, SField::ref name)
|
||||
std::unique_ptr<STBase>
|
||||
STUInt32::deserialize (SerializerIterator& sit, SField::ref name)
|
||||
{
|
||||
return new STUInt32 (name, u.get32 ());
|
||||
return std::make_unique <STUInt32> (name, sit.get32 ());
|
||||
}
|
||||
|
||||
template <>
|
||||
std::string STUInt32::getText () const
|
||||
std::string
|
||||
STUInt32::getText () const
|
||||
{
|
||||
return beast::lexicalCastThrow <std::string> (value_);
|
||||
}
|
||||
|
||||
template <>
|
||||
Json::Value STUInt32::getJson (int) const
|
||||
Json::Value
|
||||
STUInt32::getJson (int) const
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template <>
|
||||
SerializedTypeID STUInt64::getSType () const
|
||||
SerializedTypeID
|
||||
STUInt64::getSType () const
|
||||
{
|
||||
return STI_UINT64;
|
||||
}
|
||||
|
||||
template <>
|
||||
STUInt64* STUInt64::construct (SerializerIterator& u, SField::ref name)
|
||||
std::unique_ptr<STBase>
|
||||
STUInt64::deserialize (SerializerIterator& sit, SField::ref name)
|
||||
{
|
||||
return new STUInt64 (name, u.get64 ());
|
||||
return std::make_unique <STUInt64> (name, sit.get64 ());
|
||||
}
|
||||
|
||||
template <>
|
||||
std::string STUInt64::getText () const
|
||||
std::string
|
||||
STUInt64::getText () const
|
||||
{
|
||||
return beast::lexicalCastThrow <std::string> (value_);
|
||||
}
|
||||
|
||||
template <>
|
||||
Json::Value STUInt64::getJson (int) const
|
||||
Json::Value
|
||||
STUInt64::getJson (int) const
|
||||
{
|
||||
return strHex (value_);
|
||||
}
|
||||
|
||||
@@ -373,7 +373,6 @@ void STObject::add (Serializer& s, bool withSigningFields) const
|
||||
}
|
||||
}
|
||||
|
||||
typedef std::map<int, const STBase*>::value_type field_iterator;
|
||||
for (auto const& mapEntry : fields)
|
||||
{
|
||||
// insert them in sorted order
|
||||
@@ -741,13 +740,13 @@ Blob STObject::getFieldVL (SField::ref field) const
|
||||
|
||||
STAmount const& STObject::getFieldAmount (SField::ref field) const
|
||||
{
|
||||
static STAmount const empty;
|
||||
static STAmount const empty{};
|
||||
return getFieldByConstRef <STAmount> (field, empty);
|
||||
}
|
||||
|
||||
const STArray& STObject::getFieldArray (SField::ref field) const
|
||||
{
|
||||
static STArray const empty;
|
||||
static STArray const empty{};
|
||||
return getFieldByConstRef <STArray> (field, empty);
|
||||
}
|
||||
|
||||
|
||||
@@ -695,10 +695,8 @@ static bool parseObject (
|
||||
boost::ptr_vector<STBase> data;
|
||||
Json::Value::Members members (json.getMemberNames ());
|
||||
|
||||
for (Json::Value::Members::iterator it (members.begin ());
|
||||
it != members.end (); ++it)
|
||||
for (auto const& fieldName : members)
|
||||
{
|
||||
std::string const& fieldName = *it;
|
||||
Json::Value const& value = json [fieldName];
|
||||
|
||||
SField::ref field = SField::getField (fieldName);
|
||||
|
||||
@@ -50,31 +50,33 @@ STPathElement::get_hash (STPathElement const& element)
|
||||
return (hash_account ^ hash_currency ^ hash_issuer);
|
||||
}
|
||||
|
||||
STPathSet* STPathSet::construct (SerializerIterator& s, SField::ref name)
|
||||
std::unique_ptr<STBase>
|
||||
STPathSet::deserialize (SerializerIterator& sit, SField::ref name)
|
||||
{
|
||||
std::vector<STPath> paths;
|
||||
std::vector<STPathElement> path;
|
||||
|
||||
auto pathset = std::make_unique <STPathSet> (name);
|
||||
|
||||
do
|
||||
{
|
||||
int iType = s.get8 ();
|
||||
int iType = sit.get8 ();
|
||||
|
||||
if (iType == STPathElement::typeNone ||
|
||||
iType == STPathElement::typeBoundary)
|
||||
{
|
||||
if (path.empty ())
|
||||
{
|
||||
WriteLog (lsINFO, STBase) << "STPathSet: Empty path.";
|
||||
|
||||
WriteLog (lsINFO, STBase)
|
||||
<< "STPathSet: Empty path.";
|
||||
throw std::runtime_error ("empty path");
|
||||
}
|
||||
|
||||
paths.push_back (path);
|
||||
pathset->push_back (path);
|
||||
path.clear ();
|
||||
|
||||
if (iType == STPathElement::typeNone)
|
||||
{
|
||||
return new STPathSet (name, paths);
|
||||
return std::move (pathset);
|
||||
}
|
||||
}
|
||||
else if (iType & ~STPathElement::typeAll)
|
||||
@@ -95,13 +97,13 @@ STPathSet* STPathSet::construct (SerializerIterator& s, SField::ref name)
|
||||
Account issuer;
|
||||
|
||||
if (hasAccount)
|
||||
account.copyFrom (s.get160 ());
|
||||
account.copyFrom (sit.get160 ());
|
||||
|
||||
if (hasCurrency)
|
||||
currency.copyFrom (s.get160 ());
|
||||
currency.copyFrom (sit.get160 ());
|
||||
|
||||
if (hasIssuer)
|
||||
issuer.copyFrom (s.get160 ());
|
||||
issuer.copyFrom (sit.get160 ());
|
||||
|
||||
path.emplace_back (account, currency, issuer, hasCurrency);
|
||||
}
|
||||
@@ -109,13 +111,36 @@ STPathSet* STPathSet::construct (SerializerIterator& s, SField::ref name)
|
||||
while (1);
|
||||
}
|
||||
|
||||
bool STPathSet::isEquivalent (const STBase& t) const
|
||||
bool
|
||||
STPathSet::assembleAdd(STPath const& base, STPathElement const& tail)
|
||||
{ // assemble base+tail and add it to the set if it's not a duplicate
|
||||
value.push_back (base);
|
||||
|
||||
std::vector<STPath>::reverse_iterator it = value.rbegin ();
|
||||
|
||||
STPath& newPath = *it;
|
||||
newPath.push_back (tail);
|
||||
|
||||
while (++it != value.rend ())
|
||||
{
|
||||
if (*it == newPath)
|
||||
{
|
||||
value.pop_back ();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
STPathSet::isEquivalent (const STBase& t) const
|
||||
{
|
||||
const STPathSet* v = dynamic_cast<const STPathSet*> (&t);
|
||||
return v && (value == v->value);
|
||||
}
|
||||
|
||||
bool STPath::hasSeen (
|
||||
bool
|
||||
STPath::hasSeen (
|
||||
Account const& account, Currency const& currency,
|
||||
Account const& issuer) const
|
||||
{
|
||||
@@ -130,7 +155,8 @@ bool STPath::hasSeen (
|
||||
return false;
|
||||
}
|
||||
|
||||
Json::Value STPath::getJson (int) const
|
||||
Json::Value
|
||||
STPath::getJson (int) const
|
||||
{
|
||||
Json::Value ret (Json::arrayValue);
|
||||
|
||||
@@ -157,7 +183,8 @@ Json::Value STPath::getJson (int) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
Json::Value STPathSet::getJson (int options) const
|
||||
Json::Value
|
||||
STPathSet::getJson (int options) const
|
||||
{
|
||||
Json::Value ret (Json::arrayValue);
|
||||
for (auto it: value)
|
||||
@@ -166,7 +193,8 @@ Json::Value STPathSet::getJson (int options) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
void STPathSet::add (Serializer& s) const
|
||||
void
|
||||
STPathSet::add (Serializer& s) const
|
||||
{
|
||||
assert (fName->isBinary ());
|
||||
assert (fName->fieldType == STI_PATHSET);
|
||||
|
||||
@@ -22,56 +22,53 @@
|
||||
#include <ripple/basics/StringUtilities.h>
|
||||
#include <ripple/protocol/JsonFields.h>
|
||||
#include <ripple/protocol/STVector256.h>
|
||||
#include <ripple/protocol/STAmount.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
const STAmount saZero (noIssue(), 0u);
|
||||
const STAmount saOne (noIssue(), 1u);
|
||||
|
||||
//
|
||||
// STVector256
|
||||
//
|
||||
|
||||
// Return a new object from a SerializerIterator.
|
||||
STVector256* STVector256::construct (SerializerIterator& u, SField::ref name)
|
||||
std::unique_ptr<STBase>
|
||||
STVector256::deserialize (SerializerIterator& sit, SField::ref name)
|
||||
{
|
||||
Blob data = u.getVL ();
|
||||
Blob ::iterator begin = data.begin ();
|
||||
auto vec = std::make_unique<STVector256> (name);
|
||||
|
||||
std::unique_ptr<STVector256> vec (new STVector256 (name));
|
||||
Blob data = sit.getVL ();
|
||||
|
||||
auto const count = data.size () / (256 / 8);
|
||||
|
||||
int count = data.size () / (256 / 8);
|
||||
vec->mValue.reserve (count);
|
||||
|
||||
Blob::iterator begin = data.begin ();
|
||||
unsigned int uStart = 0;
|
||||
|
||||
for (unsigned int i = 0; i != count; i++)
|
||||
{
|
||||
unsigned int uEnd = uStart + (256 / 8);
|
||||
|
||||
// This next line could be optimized to construct a default uint256 in the vector and then copy into it
|
||||
// This next line could be optimized to construct a default uint256
|
||||
// in the vector and then copy into it
|
||||
vec->mValue.push_back (uint256 (Blob (begin + uStart, begin + uEnd)));
|
||||
uStart = uEnd;
|
||||
}
|
||||
|
||||
return vec.release ();
|
||||
return std::move (vec);
|
||||
}
|
||||
|
||||
void STVector256::add (Serializer& s) const
|
||||
void
|
||||
STVector256::add (Serializer& s) const
|
||||
{
|
||||
assert (fName->isBinary ());
|
||||
assert (fName->fieldType == STI_VECTOR256);
|
||||
s.addVL (mValue.empty () ? nullptr : mValue[0].begin (), mValue.size () * (256 / 8));
|
||||
}
|
||||
|
||||
bool STVector256::isEquivalent (const STBase& t) const
|
||||
bool
|
||||
STVector256::isEquivalent (const STBase& t) const
|
||||
{
|
||||
const STVector256* v = dynamic_cast<const STVector256*> (&t);
|
||||
return v && (mValue == v->mValue);
|
||||
}
|
||||
|
||||
Json::Value STVector256::getJson (int) const
|
||||
Json::Value
|
||||
STVector256::getJson (int) const
|
||||
{
|
||||
Json::Value ret (Json::arrayValue);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include <ripple/app/ledger/AcceptedLedger.h>
|
||||
#include <ripple/basics/UptimeTimer.h>
|
||||
#include <ripple/nodestore/Database.h>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -43,7 +42,7 @@ Json::Value doGetCounts (RPC::Context& context)
|
||||
|
||||
Json::Value ret (Json::objectValue);
|
||||
|
||||
BOOST_FOREACH (CountedObjects::Entry& it, objectCounts)
|
||||
for (auto const& it : objectCounts)
|
||||
{
|
||||
ret [it.first] = it.second;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ Json::Value doLogLevel (RPC::Context& context)
|
||||
std::vector< std::pair<std::string, std::string> > logTable (
|
||||
deprecatedLogs().partition_severities());
|
||||
typedef std::map<std::string, std::string>::value_type stringPair;
|
||||
BOOST_FOREACH (const stringPair & it, logTable)
|
||||
for (auto const& it : logTable)
|
||||
lev[it.first] = it.second;
|
||||
|
||||
ret["levels"] = lev;
|
||||
|
||||
Reference in New Issue
Block a user