Change how we decide whether to request a fetch pack.

This commit is contained in:
JoelKatz
2013-08-12 22:49:12 -07:00
parent 4d3d36ee47
commit df4bb9f1f4
2 changed files with 3 additions and 32 deletions

View File

@@ -32,9 +32,7 @@ NetworkOPs::NetworkOPs (LedgerMaster* pLedgerMaster)
, mLastCloseTime (0)
, mLastValidationTime (0)
, mFetchPack ("FetchPack", 2048, 20)
, mLastFetchPack (0)
// VFALCO TODO Give this magic number a name
, mFetchSeq (static_cast <uint32> (-1))
, mFetchSeq (0)
, mLastLoadBase (256)
, mLastLoadFactor (256)
{
@@ -2351,28 +2349,9 @@ bool NetworkOPs::getFetchPack (uint256 const& hash, Blob& data)
bool NetworkOPs::shouldFetchPack (uint32 seq)
{
uint32 now = getNetworkTimeNC ();
if (mLastFetchPack == now)
if (mFetchSeq == seq);
return false;
if (seq < mFetchSeq) // fetch pack has only data for ledgers ahead of where we are
mFetchPack.clear ();
else
mFetchPack.sweep ();
int size = mFetchPack.getCacheSize ();
if (size == 0)
{
mFetchSeq = 0;
}
else if (size > 128)
{
return false;
}
mLastFetchPack = now;
mFetchSeq = seq;
return true;
}
@@ -2383,8 +2362,6 @@ int NetworkOPs::getFetchSize ()
void NetworkOPs::gotFetchPack (bool progress, uint32 seq)
{
mLastFetchPack = 0;
mFetchSeq = seq; // earliest pack we have data on
getApp().getJobQueue ().addJob (jtLEDGER_DATA, "gotFetchPack",
BIND_TYPE (&InboundLedgers::gotFetchPack, &getApp().getInboundLedgers (), P_1));
}

View File

@@ -433,12 +433,6 @@ private:
SubMapType mSubRTTransactions; // all proposed and accepted transactions
TaggedCache< uint256, Blob , UptimeTimerAdapter > mFetchPack;
uint32 mLastFetchPack;
// VFALCO TODO Document the special value uint32(-1) for this member
// and replace uint32(-1) with a constant. It is initialized
// in the ctor-initializer list to this constant.
//
uint32 mFetchSeq;
uint32 mLastLoadBase;