mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 06:25:51 +00:00
Use abstract_clock
This commit is contained in:
@@ -31,9 +31,10 @@ public:
|
|||||||
|
|
||||||
static char const* getCountedObjectName () { return "LedgerConsensus"; }
|
static char const* getCountedObjectName () { return "LedgerConsensus"; }
|
||||||
|
|
||||||
LedgerConsensusImp (LedgerHash const & prevLCLHash,
|
LedgerConsensusImp (clock_type& clock, LedgerHash const & prevLCLHash,
|
||||||
Ledger::ref previousLedger, uint32 closeTime)
|
Ledger::ref previousLedger, uint32 closeTime)
|
||||||
: mState (lcsPRE_CLOSE)
|
: m_clock (clock)
|
||||||
|
, mState (lcsPRE_CLOSE)
|
||||||
, mCloseTime (closeTime)
|
, mCloseTime (closeTime)
|
||||||
, mPrevLedgerHash (prevLCLHash)
|
, mPrevLedgerHash (prevLCLHash)
|
||||||
, mPreviousLedger (previousLedger)
|
, mPreviousLedger (previousLedger)
|
||||||
@@ -280,7 +281,8 @@ public:
|
|||||||
return empty;
|
return empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
acquiring = boost::make_shared<TransactionAcquire> (hash);
|
acquiring = boost::make_shared<TransactionAcquire> (
|
||||||
|
std::ref (m_clock), hash);
|
||||||
startAcquiring (acquiring);
|
startAcquiring (acquiring);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1855,6 +1857,8 @@ private:
|
|||||||
val->setFieldU32(sfLoadFee, fee);
|
val->setFieldU32(sfLoadFee, fee);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
|
clock_type& m_clock;
|
||||||
|
|
||||||
// VFALCO TODO Rename these to look pretty
|
// VFALCO TODO Rename these to look pretty
|
||||||
enum LCState
|
enum LCState
|
||||||
{
|
{
|
||||||
@@ -1910,12 +1914,9 @@ LedgerConsensus::~LedgerConsensus ()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr <LedgerConsensus> LedgerConsensus::New(LedgerHash const & prevLCLHash,
|
boost::shared_ptr <LedgerConsensus> LedgerConsensus::New (clock_type& clock,
|
||||||
Ledger::ref previousLedger, uint32 closeTime)
|
LedgerHash const &prevLCLHash, Ledger::ref previousLedger, uint32 closeTime)
|
||||||
{
|
{
|
||||||
return boost::make_shared<LedgerConsensusImp>(
|
return boost::make_shared <LedgerConsensusImp> (
|
||||||
prevLCLHash, previousLedger,closeTime);
|
clock, prevLCLHash, previousLedger,closeTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// vim:ts=4
|
|
||||||
|
|||||||
@@ -28,7 +28,9 @@
|
|||||||
class LedgerConsensus
|
class LedgerConsensus
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static shared_ptr <LedgerConsensus> New(
|
typedef abstract_clock <std::chrono::seconds> clock_type;
|
||||||
|
|
||||||
|
static boost::shared_ptr <LedgerConsensus> New (clock_type& clock,
|
||||||
LedgerHash const & prevLCLHash, Ledger::ref previousLedger,
|
LedgerHash const & prevLCLHash, Ledger::ref previousLedger,
|
||||||
uint32 closeTime);
|
uint32 closeTime);
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ SETUP_LOG (InboundLedger)
|
|||||||
#define LEDGER_TIMEOUT_COUNT 10 // how many timeouts before we giveup
|
#define LEDGER_TIMEOUT_COUNT 10 // how many timeouts before we giveup
|
||||||
#define LEDGER_TIMEOUT_AGGRESSIVE 6 // how many timeouts before we get aggressive
|
#define LEDGER_TIMEOUT_AGGRESSIVE 6 // how many timeouts before we get aggressive
|
||||||
|
|
||||||
InboundLedger::InboundLedger (uint256 const& hash, uint32 seq)
|
InboundLedger::InboundLedger (clock_type& clock, uint256 const& hash, uint32 seq)
|
||||||
: PeerSet (hash, LEDGER_ACQUIRE_TIMEOUT, false)
|
: PeerSet (clock, hash, LEDGER_ACQUIRE_TIMEOUT, false)
|
||||||
, mHaveBase (false)
|
, mHaveBase (false)
|
||||||
, mHaveState (false)
|
, mHaveState (false)
|
||||||
, mHaveTransactions (false)
|
, mHaveTransactions (false)
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ public:
|
|||||||
typedef std::pair < boost::weak_ptr<Peer>, boost::shared_ptr<protocol::TMLedgerData> > PeerDataPairType;
|
typedef std::pair < boost::weak_ptr<Peer>, boost::shared_ptr<protocol::TMLedgerData> > PeerDataPairType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InboundLedger (uint256 const& hash, uint32 seq);
|
InboundLedger (clock_type& clock, uint256 const& hash, uint32 seq);
|
||||||
|
|
||||||
virtual ~InboundLedger ();
|
~InboundLedger ();
|
||||||
|
|
||||||
bool isBase () const
|
bool isBase () const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,12 +28,12 @@ public:
|
|||||||
// How long before we try again to acquire the same ledger
|
// How long before we try again to acquire the same ledger
|
||||||
static const int kReacquireIntervalSeconds = 300;
|
static const int kReacquireIntervalSeconds = 300;
|
||||||
|
|
||||||
explicit InboundLedgersImp (Stoppable& parent)
|
InboundLedgersImp (clock_type& clock, Stoppable& parent)
|
||||||
: Stoppable ("InboundLedgers", parent)
|
: Stoppable ("InboundLedgers", parent)
|
||||||
|
, m_clock (clock)
|
||||||
, mLock (this, "InboundLedger", __FILE__, __LINE__)
|
, mLock (this, "InboundLedger", __FILE__, __LINE__)
|
||||||
, mRecentFailures ("LedgerAcquireRecentFailures",
|
, mRecentFailures ("LedgerAcquireRecentFailures",
|
||||||
get_abstract_clock <std::chrono::steady_clock, std::chrono::seconds> (),
|
clock, 0, kReacquireIntervalSeconds)
|
||||||
0, kReacquireIntervalSeconds)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ public:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret = boost::make_shared<InboundLedger> (hash, seq);
|
ret = boost::make_shared <InboundLedger> (std::ref (m_clock), hash, seq);
|
||||||
assert (ret);
|
assert (ret);
|
||||||
mLedgers.insert (std::make_pair (hash, ret));
|
mLedgers.insert (std::make_pair (hash, ret));
|
||||||
ret->init (sl, couldBeNew);
|
ret->init (sl, couldBeNew);
|
||||||
@@ -335,7 +335,7 @@ public:
|
|||||||
{
|
{
|
||||||
mRecentFailures.sweep ();
|
mRecentFailures.sweep ();
|
||||||
|
|
||||||
int const now = UptimeTimer::getInstance ().getElapsedSeconds ();
|
clock_type::time_point const now (m_clock.now());
|
||||||
|
|
||||||
// Make a list of things to sweep, while holding the lock
|
// Make a list of things to sweep, while holding the lock
|
||||||
std::vector <MapType::mapped_type> stuffToSweep;
|
std::vector <MapType::mapped_type> stuffToSweep;
|
||||||
@@ -353,7 +353,7 @@ public:
|
|||||||
it->second->touch ();
|
it->second->touch ();
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
else if ((it->second->getLastAction () + 60) < now)
|
else if ((it->second->getLastAction () + std::chrono::minutes (1)) < now)
|
||||||
{
|
{
|
||||||
stuffToSweep.push_back (it->second);
|
stuffToSweep.push_back (it->second);
|
||||||
// shouldn't cause the actual final delete
|
// shouldn't cause the actual final delete
|
||||||
@@ -383,6 +383,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
clock_type& m_clock;
|
||||||
|
|
||||||
typedef boost::unordered_map <uint256, InboundLedger::pointer> MapType;
|
typedef boost::unordered_map <uint256, InboundLedger::pointer> MapType;
|
||||||
|
|
||||||
typedef RippleRecursiveMutex LockType;
|
typedef RippleRecursiveMutex LockType;
|
||||||
@@ -390,7 +392,7 @@ private:
|
|||||||
LockType mLock;
|
LockType mLock;
|
||||||
|
|
||||||
MapType mLedgers;
|
MapType mLedgers;
|
||||||
KeyCache <uint256, UptimeTimerAdapter> mRecentFailures;
|
KeyCache <uint256> mRecentFailures;
|
||||||
|
|
||||||
uint256 mConsensusLedger;
|
uint256 mConsensusLedger;
|
||||||
uint256 mValidationLedger;
|
uint256 mValidationLedger;
|
||||||
@@ -402,9 +404,9 @@ InboundLedgers::~InboundLedgers()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
InboundLedgers* InboundLedgers::New (Stoppable& parent)
|
InboundLedgers* InboundLedgers::New (clock_type& clock, Stoppable& parent)
|
||||||
{
|
{
|
||||||
return new InboundLedgersImp (parent);
|
return new InboundLedgersImp (clock, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,9 +27,14 @@
|
|||||||
class InboundLedgers
|
class InboundLedgers
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
typedef abstract_clock <std::chrono::seconds> clock_type;
|
||||||
|
|
||||||
virtual ~InboundLedgers() = 0;
|
virtual ~InboundLedgers() = 0;
|
||||||
|
|
||||||
static InboundLedgers* New (Stoppable& parent);
|
// VFALCO TODO Make this a free function outside the class:
|
||||||
|
// std::unique_ptr <InboundLedger> make_InboundLedgers (...)
|
||||||
|
//
|
||||||
|
static InboundLedgers* New (clock_type& clock, Stoppable& parent);
|
||||||
|
|
||||||
// VFALCO TODO Should this be called findOrAdd ?
|
// VFALCO TODO Should this be called findOrAdd ?
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -220,8 +220,9 @@ public:
|
|||||||
*m_jobQueue, LogPartition::getJournal <LedgerMaster> ()))
|
*m_jobQueue, LogPartition::getJournal <LedgerMaster> ()))
|
||||||
|
|
||||||
// VFALCO NOTE Does NetworkOPs depend on LedgerMaster?
|
// VFALCO NOTE Does NetworkOPs depend on LedgerMaster?
|
||||||
, m_networkOPs (NetworkOPs::New (
|
, m_networkOPs (NetworkOPs::New (get_abstract_clock <
|
||||||
*m_ledgerMaster, *m_jobQueue, LogPartition::getJournal <NetworkOPsLog> ()))
|
std::chrono::steady_clock, std::chrono::seconds> (), *m_ledgerMaster,
|
||||||
|
*m_jobQueue, LogPartition::getJournal <NetworkOPsLog> ()))
|
||||||
|
|
||||||
// VFALCO NOTE LocalCredentials starts the deprecated UNL service
|
// VFALCO NOTE LocalCredentials starts the deprecated UNL service
|
||||||
, m_deprecatedUNL (UniqueNodeList::New (*m_jobQueue))
|
, m_deprecatedUNL (UniqueNodeList::New (*m_jobQueue))
|
||||||
@@ -238,7 +239,8 @@ public:
|
|||||||
|
|
||||||
, m_sntpClient (SNTPClient::New (*this))
|
, m_sntpClient (SNTPClient::New (*this))
|
||||||
|
|
||||||
, m_inboundLedgers (InboundLedgers::New (*m_jobQueue))
|
, m_inboundLedgers (InboundLedgers::New (get_abstract_clock <
|
||||||
|
std::chrono::steady_clock, std::chrono::seconds> (), *m_jobQueue))
|
||||||
|
|
||||||
, m_txQueue (TxQueue::New ())
|
, m_txQueue (TxQueue::New ())
|
||||||
|
|
||||||
|
|||||||
@@ -33,8 +33,10 @@ public:
|
|||||||
public:
|
public:
|
||||||
// VFALCO TODO Make LedgerMaster a SharedPtr or a reference.
|
// VFALCO TODO Make LedgerMaster a SharedPtr or a reference.
|
||||||
//
|
//
|
||||||
NetworkOPsImp (LedgerMaster& ledgerMaster, Stoppable& parent, Journal journal)
|
NetworkOPsImp (clock_type& clock, LedgerMaster& ledgerMaster,
|
||||||
|
Stoppable& parent, Journal journal)
|
||||||
: NetworkOPs (parent)
|
: NetworkOPs (parent)
|
||||||
|
, m_clock (clock)
|
||||||
, m_journal (journal)
|
, m_journal (journal)
|
||||||
, mLock (this, "NetOPs", __FILE__, __LINE__)
|
, mLock (this, "NetOPs", __FILE__, __LINE__)
|
||||||
, mMode (omDISCONNECTED)
|
, mMode (omDISCONNECTED)
|
||||||
@@ -407,6 +409,8 @@ private:
|
|||||||
void pubServer ();
|
void pubServer ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
clock_type& m_clock;
|
||||||
|
|
||||||
typedef boost::unordered_map <uint160, SubMapType> SubInfoMapType;
|
typedef boost::unordered_map <uint160, SubMapType> SubInfoMapType;
|
||||||
typedef boost::unordered_map <uint160, SubMapType>::iterator SubInfoMapIterator;
|
typedef boost::unordered_map <uint160, SubMapType>::iterator SubInfoMapIterator;
|
||||||
|
|
||||||
@@ -1410,7 +1414,7 @@ int NetworkOPsImp::beginConsensus (uint256 const& networkClosed, Ledger::pointer
|
|||||||
assert (!mConsensus);
|
assert (!mConsensus);
|
||||||
prevLedger->setImmutable ();
|
prevLedger->setImmutable ();
|
||||||
|
|
||||||
mConsensus = LedgerConsensus::New(
|
mConsensus = LedgerConsensus::New (m_clock,
|
||||||
networkClosed, prevLedger,
|
networkClosed, prevLedger,
|
||||||
m_ledgerMaster.getCurrentLedger ()->getCloseTimeNC ());
|
m_ledgerMaster.getCurrentLedger ()->getCloseTimeNC ());
|
||||||
|
|
||||||
@@ -3104,10 +3108,14 @@ NetworkOPs::NetworkOPs (Stoppable& parent)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NetworkOPs::~NetworkOPs ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
NetworkOPs* NetworkOPs::New (LedgerMaster& ledgerMaster,
|
NetworkOPs* NetworkOPs::New (clock_type& clock, LedgerMaster& ledgerMaster,
|
||||||
Stoppable& parent, Journal journal)
|
Stoppable& parent, Journal journal)
|
||||||
{
|
{
|
||||||
return new NetworkOPsImp (ledgerMaster, parent, journal);
|
return new NetworkOPsImp (clock, ledgerMaster, parent, journal);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ protected:
|
|||||||
explicit NetworkOPs (Stoppable& parent);
|
explicit NetworkOPs (Stoppable& parent);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
typedef abstract_clock <std::chrono::seconds> clock_type;
|
||||||
|
|
||||||
enum Fault
|
enum Fault
|
||||||
{
|
{
|
||||||
// exceptions these functions can throw
|
// exceptions these functions can throw
|
||||||
@@ -80,10 +82,10 @@ public:
|
|||||||
public:
|
public:
|
||||||
// VFALCO TODO Make LedgerMaster a SharedPtr or a reference.
|
// VFALCO TODO Make LedgerMaster a SharedPtr or a reference.
|
||||||
//
|
//
|
||||||
static NetworkOPs* New (LedgerMaster& ledgerMaster,
|
static NetworkOPs* New (clock_type& clock, LedgerMaster& ledgerMaster,
|
||||||
Stoppable& parent, Journal journal);
|
Stoppable& parent, Journal journal);
|
||||||
|
|
||||||
virtual ~NetworkOPs () { }
|
virtual ~NetworkOPs () = 0;
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -19,7 +19,8 @@
|
|||||||
|
|
||||||
class InboundLedger;
|
class InboundLedger;
|
||||||
|
|
||||||
PeerSet::PeerSet (uint256 const& hash, int interval, bool txnData)
|
PeerSet::PeerSet (clock_type& clock_,
|
||||||
|
uint256 const& hash, int interval, bool txnData)
|
||||||
: mLock (this, "PeerSet", __FILE__, __LINE__)
|
: mLock (this, "PeerSet", __FILE__, __LINE__)
|
||||||
, mHash (hash)
|
, mHash (hash)
|
||||||
, mTimerInterval (interval)
|
, mTimerInterval (interval)
|
||||||
@@ -30,11 +31,21 @@ PeerSet::PeerSet (uint256 const& hash, int interval, bool txnData)
|
|||||||
, mTxnData (txnData)
|
, mTxnData (txnData)
|
||||||
, mProgress (false)
|
, mProgress (false)
|
||||||
, mTimer (getApp().getIOService ())
|
, mTimer (getApp().getIOService ())
|
||||||
|
, m_clock (clock_)
|
||||||
{
|
{
|
||||||
mLastAction = UptimeTimer::getInstance ().getElapsedSeconds ();
|
mLastAction = clock().now();
|
||||||
assert ((mTimerInterval > 10) && (mTimerInterval < 30000));
|
assert ((mTimerInterval > 10) && (mTimerInterval < 30000));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PeerSet::~PeerSet ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PeerSet::clock_type& PeerSet::clock ()
|
||||||
|
{
|
||||||
|
return m_clock;
|
||||||
|
}
|
||||||
|
|
||||||
bool PeerSet::peerHas (Peer::ref ptr)
|
bool PeerSet::peerHas (Peer::ref ptr)
|
||||||
{
|
{
|
||||||
ScopedLockType sl (mLock, __FILE__, __LINE__);
|
ScopedLockType sl (mLock, __FILE__, __LINE__);
|
||||||
@@ -139,7 +150,7 @@ void PeerSet::sendRequest (const protocol::TMGetLedger& tmGL)
|
|||||||
|
|
||||||
PackedMessage::pointer packet = boost::make_shared<PackedMessage> (tmGL, protocol::mtGET_LEDGER);
|
PackedMessage::pointer packet = boost::make_shared<PackedMessage> (tmGL, protocol::mtGET_LEDGER);
|
||||||
|
|
||||||
for (boost::unordered_map<uint64, int>::iterator it = mPeers.begin (), end = mPeers.end (); it != end; ++it)
|
for (Map::iterator it = mPeers.begin (), end = mPeers.end (); it != end; ++it)
|
||||||
{
|
{
|
||||||
Peer::pointer peer = getApp().getPeers ().getPeerById (it->first);
|
Peer::pointer peer = getApp().getPeers ().getPeerById (it->first);
|
||||||
|
|
||||||
@@ -153,7 +164,7 @@ int PeerSet::takePeerSetFrom (const PeerSet& s)
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
mPeers.clear ();
|
mPeers.clear ();
|
||||||
|
|
||||||
for (boost::unordered_map<uint64, int>::const_iterator it = s.mPeers.begin (), end = s.mPeers.end ();
|
for (Map::const_iterator it = s.mPeers.begin (), end = s.mPeers.end ();
|
||||||
it != end; ++it)
|
it != end; ++it)
|
||||||
{
|
{
|
||||||
mPeers.insert (std::make_pair (it->first, 0));
|
mPeers.insert (std::make_pair (it->first, 0));
|
||||||
@@ -167,7 +178,7 @@ int PeerSet::getPeerCount () const
|
|||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
for (boost::unordered_map<uint64, int>::const_iterator it = mPeers.begin (), end = mPeers.end (); it != end; ++it)
|
for (Map::const_iterator it = mPeers.begin (), end = mPeers.end (); it != end; ++it)
|
||||||
if (getApp().getPeers ().hasPeer (it->first))
|
if (getApp().getPeers ().hasPeer (it->first))
|
||||||
++ret;
|
++ret;
|
||||||
|
|
||||||
|
|||||||
@@ -27,42 +27,52 @@
|
|||||||
class PeerSet : LeakChecked <PeerSet>
|
class PeerSet : LeakChecked <PeerSet>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
typedef abstract_clock <std::chrono::seconds> clock_type;
|
||||||
|
|
||||||
uint256 const& getHash () const
|
uint256 const& getHash () const
|
||||||
{
|
{
|
||||||
return mHash;
|
return mHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isComplete () const
|
bool isComplete () const
|
||||||
{
|
{
|
||||||
return mComplete;
|
return mComplete;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isFailed () const
|
bool isFailed () const
|
||||||
{
|
{
|
||||||
return mFailed;
|
return mFailed;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getTimeouts () const
|
int getTimeouts () const
|
||||||
{
|
{
|
||||||
return mTimeouts;
|
return mTimeouts;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isActive ();
|
bool isActive ();
|
||||||
|
|
||||||
void progress ()
|
void progress ()
|
||||||
{
|
{
|
||||||
mProgress = true;
|
mProgress = true;
|
||||||
mAggressive = false;
|
mAggressive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearProgress ()
|
void clearProgress ()
|
||||||
{
|
{
|
||||||
mProgress = false;
|
mProgress = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isProgress ()
|
bool isProgress ()
|
||||||
{
|
{
|
||||||
return mProgress;
|
return mProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
void touch ()
|
void touch ()
|
||||||
{
|
{
|
||||||
mLastAction = UptimeTimer::getInstance ().getElapsedSeconds ();
|
mLastAction = clock().now();
|
||||||
}
|
}
|
||||||
int getLastAction ()
|
|
||||||
|
clock_type::time_point getLastAction () const
|
||||||
{
|
{
|
||||||
return mLastAction;
|
return mLastAction;
|
||||||
}
|
}
|
||||||
@@ -92,13 +102,15 @@ private:
|
|||||||
static void TimerEntry (boost::weak_ptr<PeerSet>, const boost::system::error_code& result);
|
static void TimerEntry (boost::weak_ptr<PeerSet>, const boost::system::error_code& result);
|
||||||
static void TimerJobEntry (Job&, boost::shared_ptr<PeerSet>);
|
static void TimerJobEntry (Job&, boost::shared_ptr<PeerSet>);
|
||||||
|
|
||||||
// VFALCO TODO try to make some of these private
|
|
||||||
protected:
|
protected:
|
||||||
|
clock_type& clock ();
|
||||||
|
|
||||||
|
// VFALCO TODO try to make some of these private
|
||||||
typedef RippleRecursiveMutex LockType;
|
typedef RippleRecursiveMutex LockType;
|
||||||
typedef LockType::ScopedLockType ScopedLockType;
|
typedef LockType::ScopedLockType ScopedLockType;
|
||||||
|
|
||||||
PeerSet (uint256 const& hash, int interval, bool txnData);
|
PeerSet (clock_type& clock, uint256 const& hash, int interval, bool txnData);
|
||||||
virtual ~PeerSet () { }
|
virtual ~PeerSet () = 0;
|
||||||
|
|
||||||
virtual void newPeer (Peer::ref) = 0;
|
virtual void newPeer (Peer::ref) = 0;
|
||||||
virtual void onTimer (bool progress, ScopedLockType&) = 0;
|
virtual void onTimer (bool progress, ScopedLockType&) = 0;
|
||||||
@@ -127,7 +139,7 @@ protected:
|
|||||||
bool mFailed;
|
bool mFailed;
|
||||||
bool mAggressive;
|
bool mAggressive;
|
||||||
bool mTxnData;
|
bool mTxnData;
|
||||||
int mLastAction;
|
clock_type::time_point mLastAction;
|
||||||
bool mProgress;
|
bool mProgress;
|
||||||
|
|
||||||
|
|
||||||
@@ -137,7 +149,11 @@ protected:
|
|||||||
// VFALCO TODO Verify that these are used in the way that the names suggest.
|
// VFALCO TODO Verify that these are used in the way that the names suggest.
|
||||||
typedef uint64 PeerIdentifier;
|
typedef uint64 PeerIdentifier;
|
||||||
typedef int ReceivedChunkCount;
|
typedef int ReceivedChunkCount;
|
||||||
boost::unordered_map <PeerIdentifier, ReceivedChunkCount> mPeers;
|
typedef boost::unordered_map <PeerIdentifier, ReceivedChunkCount> Map;
|
||||||
|
Map mPeers;
|
||||||
|
|
||||||
|
private:
|
||||||
|
clock_type& m_clock;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ public:
|
|||||||
typedef std::pair<uint256, SHAMapNode> TNIndex;
|
typedef std::pair<uint256, SHAMapNode> TNIndex;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static KeyCache <uint256, UptimeTimerAdapter> fullBelowCache;
|
static KeyCache <uint256> fullBelowCache;
|
||||||
|
|
||||||
static TaggedCacheType <TNIndex, SHAMapTreeNode> treeNodeCache;
|
static TaggedCacheType <TNIndex, SHAMapTreeNode> treeNodeCache;
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,8 @@
|
|||||||
|
|
||||||
static const uint256 uZero;
|
static const uint256 uZero;
|
||||||
|
|
||||||
KeyCache <uint256, UptimeTimerAdapter> SHAMap::fullBelowCache (
|
// VFALCO TODO Put these globals into a singleton and make the clock a parameter
|
||||||
|
KeyCache <uint256> SHAMap::fullBelowCache (
|
||||||
"fullBelowCache",
|
"fullBelowCache",
|
||||||
get_abstract_clock <std::chrono::steady_clock, std::chrono::seconds> (),
|
get_abstract_clock <std::chrono::steady_clock, std::chrono::seconds> (),
|
||||||
524288, 240);
|
524288, 240);
|
||||||
|
|||||||
@@ -24,13 +24,17 @@ SETUP_LOG (TransactionAcquire)
|
|||||||
typedef std::map<uint160, LedgerProposal::pointer>::value_type u160_prop_pair;
|
typedef std::map<uint160, LedgerProposal::pointer>::value_type u160_prop_pair;
|
||||||
typedef std::map<uint256, DisputedTx::pointer>::value_type u256_lct_pair;
|
typedef std::map<uint256, DisputedTx::pointer>::value_type u256_lct_pair;
|
||||||
|
|
||||||
TransactionAcquire::TransactionAcquire (uint256 const& hash)
|
TransactionAcquire::TransactionAcquire (clock_type& clock, uint256 const& hash)
|
||||||
: PeerSet (hash, TX_ACQUIRE_TIMEOUT, true)
|
: PeerSet (clock, hash, TX_ACQUIRE_TIMEOUT, true)
|
||||||
, mHaveRoot (false)
|
, mHaveRoot (false)
|
||||||
{
|
{
|
||||||
mMap = boost::make_shared<SHAMap> (smtTRANSACTION, hash);
|
mMap = boost::make_shared<SHAMap> (smtTRANSACTION, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TransactionAcquire::~TransactionAcquire ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static void TACompletionHandler (uint256 hash, SHAMap::pointer map)
|
static void TACompletionHandler (uint256 hash, SHAMap::pointer map)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,11 +33,8 @@ public:
|
|||||||
typedef boost::shared_ptr<TransactionAcquire> pointer;
|
typedef boost::shared_ptr<TransactionAcquire> pointer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TransactionAcquire (uint256 const& hash);
|
TransactionAcquire (clock_type& clock, uint256 const& hash);
|
||||||
virtual ~TransactionAcquire ()
|
~TransactionAcquire ();
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
SHAMap::ref getMap ()
|
SHAMap::ref getMap ()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ private:
|
|||||||
clock_type::time_point last_access;
|
clock_type::time_point last_access;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::unordered_map <key_type, Entry> map_type;
|
typedef std::unordered_map <key_type, Entry, Hash, KeyEqual> map_type;
|
||||||
typedef typename map_type::iterator iterator;
|
typedef typename map_type::iterator iterator;
|
||||||
typedef std::lock_guard <Mutex> lock_guard;
|
typedef std::lock_guard <Mutex> lock_guard;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user