New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Net] Reduce preferential Graphene/Xthin timers to 1 second each #1511

Merged
merged 1 commit into from Dec 5, 2018
File filter...
Filter file types
Jump to file or symbol
Failed to load files and symbols.
+8 −8
Diff settings

Always

Just for now

Copy path View file
@@ -1182,22 +1182,22 @@ std::string CGrapheneBlockData::ReRequestedTxToString()
bool CGrapheneBlockData::CheckGrapheneBlockTimer(const uint256 &hash)
{
// Base time used to calculate the random timeout value.
static int64_t nTimeToWait = 10000;
static int64_t nTimeToWait = 1000;

LOCK(cs_mapGrapheneBlockTimer);
if (!mapGrapheneBlockTimer.count(hash))
{
// The timeout limit is a random number betwee 8 and 12 seconds.
// The timeout limit is a random number between 0.8 and 1.2 seconds.
// This way a node connected to this one may download the block
// before the other node and thus be able to serve the other with
// a graphene block, rather than both nodes timing out and downloading
// a thinblock instead. This can happen at the margins of the BU network
// where we receive full blocks from peers that don't support graphene.
//
// To make the timeout random we adjust the start time of the timer forward
// or backward by a random amount plus or minus 2 seconds.
// or backward by a random amount plus or minus 0.2 seconds.
FastRandomContext insecure_rand(false);
uint64_t nOffset = nTimeToWait - (8000 + (insecure_rand.rand64() % 4000) + 1);
uint64_t nOffset = nTimeToWait - (800 + (insecure_rand.rand64() % 400) + 1);
mapGrapheneBlockTimer[hash] = std::make_pair(GetTimeMillis() + nOffset, false);
LOG(GRAPHENE, "Starting Preferential Graphene Block timer (%d millis)\n", nTimeToWait + nOffset);
}
Copy path View file
@@ -1325,22 +1325,22 @@ std::string CThinBlockData::FullTxToString()
bool CThinBlockData::CheckThinblockTimer(const uint256 &hash)
{
// Base time used to calculate the random timeout value.
static uint64_t nTimeToWait = 10000;
static uint64_t nTimeToWait = 1000;

LOCK(cs_mapThinBlockTimer);
if (!mapThinBlockTimer.count(hash))
{
// The timeout limit is a random number betwee 8 and 12 seconds.
// The timeout limit is a random number between 0.8 and 1.2 seconds.
// This way a node connected to this one may download the block
// before the other node and thus be able to serve the other with
// a graphene block, rather than both nodes timing out and downloading
// a thinblock instead. This can happen at the margins of the BU network
// where we receive full blocks from peers that don't support graphene.
//
// To make the timeout random we adjust the start time of the timer forward
// or backward by a random amount plus or minus 2 seconds.
// or backward by a random amount plus or minus 0.2 seconds.
FastRandomContext insecure_rand(false);
uint64_t nOffset = nTimeToWait - (8000 + (insecure_rand.rand64() % 4000) + 1);
uint64_t nOffset = nTimeToWait - (800 + (insecure_rand.rand64() % 400) + 1);
mapThinBlockTimer[hash] = std::make_pair(GetTimeMillis() + nOffset, false);
LOG(THIN, "Starting Preferential Thinblock timer (%d millis)\n", nTimeToWait + nOffset);
}
ProTip! Use n and p to navigate between commits in a pull request.