From f59d8f0b644d49324cabd19c58cf2262d49e1392 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Fri, 10 Jan 2014 13:23:26 +0100 Subject: Per-peer block download tracking and stalled download detection. Keep track of which block is being requested (and to be requested) from each peer, and limit the number of blocks in-flight per peer. In addition, detect stalled downloads, and disconnect if they persist for too long. This means blocks are never requested twice, and should eliminate duplicate downloads during synchronization. --- src/main.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/main.h') diff --git a/src/main.h b/src/main.h index 05210e5164..159a665466 100644 --- a/src/main.h +++ b/src/main.h @@ -59,6 +59,11 @@ static const int COINBASE_MATURITY = 100; static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC /** Maximum number of script-checking threads allowed */ static const int MAX_SCRIPTCHECK_THREADS = 16; +/** Number of blocks that can be requested at any given time from a single peer. */ +static const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 128; +/** Timeout in seconds before considering a block download peer unresponsive. */ +static const unsigned int BLOCK_DOWNLOAD_TIMEOUT = 60; + #ifdef USE_UPNP static const int fHaveUPnP = true; #else @@ -182,6 +187,9 @@ bool VerifySignature(const CCoins& txFrom, const CTransaction& txTo, unsigned in bool AbortNode(const std::string &msg); /** Get statistics from node state */ bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats); +/** Increase a node's misbehavior score. */ +void Misbehaving(NodeId nodeid, int howmuch); + /** (try to) add transaction to memory pool **/ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree, -- cgit v1.2.3