mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Avoid excess ledger header requests
This commit is contained in:
@@ -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 ());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 ();
|
||||
|
||||
Reference in New Issue
Block a user