Skip to content

Commit ecad7c3

Browse files
author
Neil Booth
committed
Add blkretryinterval and txretryinterval arguments.
Fixes bitcoin#649
1 parent e986a6f commit ecad7c3

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

src/allowed_args.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "net.h"
1515
#include "policy/policy.h"
1616
#include "qt/guiconstants.h"
17+
#include "requestManager.h"
1718
#include "script/sigcache.h"
1819
#include "tinyformat.h"
1920
#include "torcontrol.h"
@@ -282,6 +283,9 @@ static void addConnectionOptions(AllowedArgs &allowedArgs)
282283
_("Bind to given address and always listen on it. Use [host]:port notation for IPv6"))
283284
.addArg("bitnodes", optionalBool,
284285
_("Query for peer addresses via Bitnodes API, if low on addresses (default: 1 unless -connect)"))
286+
.addArg("blkretryinterval", requiredInt,
287+
strprintf(_("Time to wait before requesting a block from a different peer, in microseconds (default: %u)"),
288+
DEFAULT_MIN_BLK_REQUEST_RETRY_INTERVAL))
285289
.addArg("connect=<ip>", optionalStr, _("Connect only to the specified node(s)"))
286290
.addArg("connect-thinblock=<ip:port>", requiredStr,
287291
_("Connect to a thinblock node(s). Blocks will only be downloaded from a thinblock peer. If no "
@@ -341,6 +345,9 @@ static void addConnectionOptions(AllowedArgs &allowedArgs)
341345
.addArg("torcontrol=<ip>:<port>", requiredStr,
342346
strprintf(_("Tor control port to use if onion listening enabled (default: %s)"), DEFAULT_TOR_CONTROL))
343347
.addArg("torpassword=<pass>", requiredStr, _("Tor control port password (default: empty)"))
348+
.addArg("txretryinterval", requiredInt,
349+
strprintf(_("Time to wait before requesting a tx from a different peer, in microseconds (default: %u)"),
350+
DEFAULT_MIN_TX_REQUEST_RETRY_INTERVAL))
344351
#ifdef USE_UPNP
345352
#if USE_UPNP
346353
.addArg("upnp", optionalBool, _("Use UPnP to map the listening port (default: 1 when listening and no -proxy)"))

src/requestManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ extern CRequestManager requester;
4545
unsigned int ACCEPTABLE_PING_USEC = 25*1000;
4646

4747
// When should I request an object from someone else (in microseconds)
48-
unsigned int MIN_TX_REQUEST_RETRY_INTERVAL = 5 * 1000 * 1000;
48+
unsigned int MIN_TX_REQUEST_RETRY_INTERVAL = DEFAULT_MIN_TX_REQUEST_RETRY_INTERVAL;
4949
// When should I request a block from someone else (in microseconds)
50-
unsigned int MIN_BLK_REQUEST_RETRY_INTERVAL = 5 * 1000 * 1000;
50+
unsigned int MIN_BLK_REQUEST_RETRY_INTERVAL = DEFAULT_MIN_BLK_REQUEST_RETRY_INTERVAL;
5151

5252
// defined in main.cpp. should be moved into a utilities file but want to make rebasing easier
5353
extern bool CanDirectFetch(const Consensus::Params &consensusParams);

src/requestManager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ successful receipt, "requester.Rejected(...)" to indicate a bad object (request
3030
#include "stat.h"
3131
// When should I request a tx from someone else (in microseconds). cmdline/bitcoin.conf: -txretryinterval
3232
extern unsigned int MIN_TX_REQUEST_RETRY_INTERVAL;
33+
static const unsigned int DEFAULT_MIN_TX_REQUEST_RETRY_INTERVAL = 5 * 1000 * 1000;
3334
// When should I request a block from someone else (in microseconds). cmdline/bitcoin.conf: -blkretryinterval
3435
extern unsigned int MIN_BLK_REQUEST_RETRY_INTERVAL;
36+
static const unsigned int DEFAULT_MIN_BLK_REQUEST_RETRY_INTERVAL = 5 * 1000 * 1000;
3537

3638
// How long in seconds we wait for a xthin request to be fullfilled before disconnecting the node.
3739
static const unsigned int THINBLOCK_DOWNLOAD_TIMEOUT = 30;

src/unlimited.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,8 @@ void settingsToUserAgentString()
382382

383383
void UnlimitedSetup(void)
384384
{
385-
MIN_TX_REQUEST_RETRY_INTERVAL = GetArg("-txretryinterval", MIN_TX_REQUEST_RETRY_INTERVAL);
386-
MIN_BLK_REQUEST_RETRY_INTERVAL = GetArg("-blkretryinterval", MIN_BLK_REQUEST_RETRY_INTERVAL);
385+
MIN_TX_REQUEST_RETRY_INTERVAL = GetArg("-txretryinterval", DEFAULT_MIN_TX_REQUEST_RETRY_INTERVAL);
386+
MIN_BLK_REQUEST_RETRY_INTERVAL = GetArg("-blkretryinterval", DEFAULT_MIN_BLK_REQUEST_RETRY_INTERVAL);
387387
maxGeneratedBlock = GetArg("-blockmaxsize", maxGeneratedBlock);
388388
blockVersion = GetArg("-blockversion", blockVersion);
389389
excessiveBlockSize = GetArg("-excessiveblocksize", excessiveBlockSize);

0 commit comments

Comments
 (0)