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