Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add find_create stat to InboundLedgers #290

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/ripple_app/ledger/InboundLedgers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ class InboundLedgersImp
// 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"))
{
}

Expand Down Expand Up @@ -61,6 +63,7 @@ class InboundLedgersImp
assert (ret);
mLedgers.insert (std::make_pair (hash, ret));
ret->init (sl, couldBeNew);
++mCounter;
}
}
}
Expand Down Expand Up @@ -396,6 +399,8 @@ class InboundLedgersImp

uint256 mConsensusLedger;
uint256 mValidationLedger;

beast::insight::Counter mCounter;
};

//------------------------------------------------------------------------------
Expand All @@ -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);
}


Expand Down
3 changes: 2 additions & 1 deletion src/ripple_app/ledger/InboundLedgers.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class InboundLedgers
// 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 ?
//
Expand Down
3 changes: 2 additions & 1 deletion src/ripple_app/main/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ class ApplicationImp
// 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,
Expand Down