mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Make the progress logic that triggers timeouts smarter.
This commit is contained in:
@@ -12,12 +12,11 @@ PeerSet::PeerSet (uint256 const& hash, int interval, bool txnData)
|
||||
, mTimeouts (0)
|
||||
, mComplete (false)
|
||||
, mFailed (false)
|
||||
, mProgress (true)
|
||||
, mAggressive (false)
|
||||
, mTxnData (txnData)
|
||||
, mTimer (getApp().getIOService ())
|
||||
{
|
||||
mLastAction = UptimeTimer::getInstance ().getElapsedSeconds ();
|
||||
mLastAction = mLastProgress = UptimeTimer::getInstance ().getElapsedSeconds ();
|
||||
assert ((mTimerInterval > 10) && (mTimerInterval < 30000));
|
||||
}
|
||||
|
||||
@@ -51,17 +50,14 @@ void PeerSet::invokeOnTimer ()
|
||||
if (isDone ())
|
||||
return;
|
||||
|
||||
if (!mProgress)
|
||||
if (!isProgress())
|
||||
{
|
||||
++mTimeouts;
|
||||
WriteLog (lsWARNING, InboundLedger) << "Timeout(" << mTimeouts << ") pc=" << mPeers.size () << " acquiring " << mHash;
|
||||
onTimer (false, sl);
|
||||
}
|
||||
else
|
||||
{
|
||||
mProgress = false;
|
||||
onTimer (true, sl);
|
||||
}
|
||||
|
||||
if (!isDone ())
|
||||
setTimer ();
|
||||
|
||||
@@ -34,12 +34,12 @@ public:
|
||||
bool isActive ();
|
||||
void progress ()
|
||||
{
|
||||
mProgress = true;
|
||||
mLastProgress = UptimeTimer::getInstance().getElapsedSeconds();
|
||||
mAggressive = false;
|
||||
}
|
||||
bool isProgress ()
|
||||
{
|
||||
return mProgress;
|
||||
return (mLastProgress + (mTimerInterval / 1000)) > UptimeTimer::getInstance().getElapsedSeconds();
|
||||
}
|
||||
void touch ()
|
||||
{
|
||||
@@ -93,10 +93,10 @@ protected:
|
||||
int mTimeouts;
|
||||
bool mComplete;
|
||||
bool mFailed;
|
||||
bool mProgress;
|
||||
bool mAggressive;
|
||||
bool mTxnData;
|
||||
int mLastAction;
|
||||
int mLastProgress;
|
||||
|
||||
|
||||
boost::recursive_mutex mLock;
|
||||
|
||||
Reference in New Issue
Block a user