Add find_create stat to InboundLedgers

This commit is contained in:
Howard Hinnant
2014-02-21 20:11:13 -05:00
committed by Vinnie Falco
parent ff80531db4
commit 382088c456
3 changed files with 13 additions and 5 deletions

View File

@@ -28,12 +28,14 @@ public:
// How long before we try again to acquire the same ledger
static const int kReacquireIntervalSeconds = 300;
InboundLedgersImp (clock_type& clock, Stoppable& parent)
InboundLedgersImp (clock_type& clock, Stoppable& parent,
insight::Collector::ptr const& collector)
: Stoppable ("InboundLedgers", parent)
, m_clock (clock)
, mLock (this, "InboundLedger", __FILE__, __LINE__)
, mRecentFailures ("LedgerAcquireRecentFailures",
clock, 0, kReacquireIntervalSeconds)
, mCounter(collector->make_counter("ledger_fetches"))
{
}
@@ -61,6 +63,7 @@ public:
assert (ret);
mLedgers.insert (std::make_pair (hash, ret));
ret->init (sl, couldBeNew);
++mCounter;
}
}
}
@@ -396,6 +399,8 @@ private:
uint256 mConsensusLedger;
uint256 mValidationLedger;
beast::insight::Counter mCounter;
};
//------------------------------------------------------------------------------
@@ -404,9 +409,10 @@ InboundLedgers::~InboundLedgers()
{
}
InboundLedgers* InboundLedgers::New (clock_type& clock, Stoppable& parent)
InboundLedgers* InboundLedgers::New (clock_type& clock, Stoppable& parent,
insight::Collector::ptr const& collector)
{
return new InboundLedgersImp (clock, parent);
return new InboundLedgersImp (clock, parent, collector);
}

View File

@@ -34,7 +34,8 @@ public:
// VFALCO TODO Make this a free function outside the class:
// std::unique_ptr <InboundLedger> make_InboundLedgers (...)
//
static InboundLedgers* New (clock_type& clock, Stoppable& parent);
static InboundLedgers* New (clock_type& clock, Stoppable& parent,
insight::Collector::ptr const& collector);
// VFALCO TODO Should this be called findOrAdd ?
//

View File

@@ -264,7 +264,8 @@ public:
// VFALCO NOTE must come before NetworkOPs to prevent a crash due
// to dependencies in the destructor.
//
, m_inboundLedgers (InboundLedgers::New (get_seconds_clock (), *m_jobQueue))
, m_inboundLedgers (InboundLedgers::New (get_seconds_clock (), *m_jobQueue,
m_collectorManager->collector ()))
// VFALCO NOTE Does NetworkOPs depend on LedgerMaster?
, m_networkOPs (NetworkOPs::New (get_seconds_clock (), *m_ledgerMaster,