Avoid excess ledger header requests

This commit is contained in:
JoelKatz
2015-02-10 00:18:02 -08:00
committed by Tom Ritchford
parent 7bd339b645
commit 382a16ff07
2 changed files with 12 additions and 7 deletions

View File

@@ -100,11 +100,6 @@ void InboundLedger::init (ScopedLockType& collectionLock)
{
addPeers ();
setTimer ();
// For historical nodes, wait a bit since a
// fetch pack is probably coming
if (mReason != fcHISTORY)
trigger (Peer::ptr ());
}
else if (!isFailed ())
{
@@ -272,9 +267,16 @@ void InboundLedger::onTimer (bool wasProgress, ScopedLockType&)
"No progress(" << pc <<
") for ledger " << mHash;
trigger (Peer::ptr ());
// addPeers triggers if the reason is not fcHISTORY
// So if the reason IS fcHISTORY, need to trigger after we add
// otherwise, we need to trigger before we add
// so each peer gets triggered once
if (mReason != fcHISTORY)
trigger (Peer::ptr ());
if (pc < 4)
addPeers ();
if (mReason == fcHISTORY)
trigger (Peer::ptr ());
}
}

View File

@@ -114,7 +114,10 @@ private:
void newPeer (Peer::ptr const& peer)
{
trigger (peer);
// For historical nodes, do not trigger too soon
// since a fetch pack is probably coming
if (mReason != fcHISTORY)
trigger (peer);
}
std::weak_ptr <PeerSet> pmDowncast ();