Rename LedgerAcquire to InboundLedger

This commit is contained in:
Vinnie Falco
2013-06-16 08:40:39 -07:00
parent 326ff5a205
commit 7eff38c1bb
22 changed files with 238 additions and 198 deletions

View File

@@ -0,0 +1,68 @@
//------------------------------------------------------------------------------
/*
Copyright (c) 2011-2013, OpenCoin, Inc.
*/
//==============================================================================
#ifndef RIPPLE_INBOUNDLEDGERS_H
#define RIPPLE_INBOUNDLEDGERS_H
/** Manages the lifetime of inbound ledgers.
@see InboundLedger
*/
// VFALCO TODO Rename to InboundLedgers
// VFALCO TODO Create abstract interface
class InboundLedgers
{
public:
// How long before we try again to acquire the same ledger
static const int kReacquireIntervalSeconds = 600;
InboundLedgers ()
: mRecentFailures ("LedgerAcquireRecentFailures", 0, kReacquireIntervalSeconds)
{
}
// VFALCO TODO Should this be called findOrAdd ?
//
InboundLedger::pointer findCreate (uint256 const& hash, uint32 seq);
InboundLedger::pointer find (uint256 const& hash);
bool hasLedger (LedgerHash const& ledgerHash);
void dropLedger (LedgerHash const& ledgerHash);
bool awaitLedgerData (LedgerHash const& ledgerHash);
// VFALCO TODO Why is hash passed by value?
// VFALCO TODO Remove the dependency on the Peer object.
//
void gotLedgerData (Job&,
LedgerHash hash,
boost::shared_ptr <ripple::TMLedgerData> packet,
boost::weak_ptr<Peer> peer);
int getFetchCount (int& timeoutCount);
void logFailure (uint256 const& h)
{
mRecentFailures.add (h);
}
bool isFailure (uint256 const& h)
{
return mRecentFailures.isPresent (h, false);
}
void gotFetchPack (Job&);
void sweep ();
private:
boost::mutex mLock;
std::map <uint256, InboundLedger::pointer> mLedgers;
KeyCache <uint256, UptimeTimerAdapter> mRecentFailures;
};
#endif