aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.h
diff options
context:
space:
mode:
authorSuhas Daftuar <sdaftuar@gmail.com>2017-05-08 15:05:22 -0400
committerSuhas Daftuar <sdaftuar@gmail.com>2017-06-05 16:33:35 -0400
commit76f74811c44b5119d5c19364b0594d423248ac0e (patch)
treeb4665449ef64f7e3c7e06b2724dcd265d8e1cb3d /src/net_processing.h
parente2652002b6011f793185d473f87f1730c625593b (diff)
downloadbitcoin-76f74811c44b5119d5c19364b0594d423248ac0e.tar.xz
Add timeout for headers sync
At startup, we choose one peer to serve us the headers chain, until our best header is close to caught up. Disconnect this peer if more than 15 minutes + 1ms/expected_header passes and our best header is still more than 1 day away from current time.
Diffstat (limited to 'src/net_processing.h')
-rw-r--r--src/net_processing.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/net_processing.h b/src/net_processing.h
index f460595bc1..db6d81e6b6 100644
--- a/src/net_processing.h
+++ b/src/net_processing.h
@@ -17,6 +17,10 @@ static const int64_t ORPHAN_TX_EXPIRE_TIME = 20 * 60;
static const int64_t ORPHAN_TX_EXPIRE_INTERVAL = 5 * 60;
/** Default number of orphan+recently-replaced txn to keep around for block reconstruction */
static const unsigned int DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN = 100;
+/** Headers download timeout expressed in microseconds
+ * Timeout = base + per_header * (expected number of headers) */
+static constexpr int64_t HEADERS_DOWNLOAD_TIMEOUT_BASE = 15 * 60 * 1000000; // 15 minutes
+static constexpr int64_t HEADERS_DOWNLOAD_TIMEOUT_PER_HEADER = 1000; // 1ms/header
/** Register with a network node to receive its signals */
void RegisterNodeSignals(CNodeSignals& nodeSignals);