Skip to content

Commit

Permalink
change broadcastdelay parameter unit to millisecond
Browse files Browse the repository at this point in the history
  • Loading branch information
ctnchain authored and Danconnolly committed Jan 29, 2019
1 parent eae077d commit a9326c7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ std::string HelpMessage(HelpMessageMode mode) {
strUsage += HelpMessageOpt(
"-broadcastdelay=<n>",
strprintf(
_("Set inventory broadcast delay duration in microsecond(min: %d, max: %d)"),
_("Set inventory broadcast delay duration in millisecond(min: %d, max: %d)"),
0,MAX_INV_BROADCAST_DELAY));
strUsage +=
HelpMessageOpt("-onion=<ip:port>",
Expand Down Expand Up @@ -1826,9 +1826,9 @@ bool AppInitMain(Config &config, boost::thread_group &threadGroup,

peerLogic.reset(new PeerLogicValidation(&connman));
if (gArgs.IsArgSet("-broadcastdelay")) {
const int64_t nDelay = gArgs.GetArg("-broadcastdelay", -1);
if(!SetInvBroadcastDelay(nDelay)){
return InitError(strprintf(_("Error setting broadcastdelay=%d"), nDelay));
const int64_t nDelayMillisecs = gArgs.GetArg("-broadcastdelay", -1);
if(!SetInvBroadcastDelay(nDelayMillisecs)){
return InitError(strprintf(_("Error setting broadcastdelay=%d"), nDelayMillisecs));
}
}
RegisterValidationInterface(peerLogic.get());
Expand Down
6 changes: 3 additions & 3 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,10 +687,10 @@ void UnregisterNodeSignals(CNodeSignals &nodeSignals) {
}

static int64_t Fixed_delay_microsecs=-1;// microsecond
bool SetInvBroadcastDelay(const int64_t& nDelay) {
if ( nDelay < 0 || nDelay > MAX_INV_BROADCAST_DELAY)
bool SetInvBroadcastDelay(const int64_t& nDelayMillisecs) {
if ( nDelayMillisecs < 0 || nDelayMillisecs > MAX_INV_BROADCAST_DELAY)
return false;
Fixed_delay_microsecs=nDelay;
Fixed_delay_microsecs=1000*nDelayMillisecs;
return true;
}

Expand Down
6 changes: 3 additions & 3 deletions src/net_processing.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ 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;
/** Max broadcast delay duration in micro seconds */
static const int64_t MAX_INV_BROADCAST_DELAY = 50 * 1000000;
/** Max broadcast delay duration in milliseconds */
static const int64_t MAX_INV_BROADCAST_DELAY = 50 * 1000;

/** Register with a network node to receive its signals */
void RegisterNodeSignals(CNodeSignals &nodeSignals);
/** Unregister a network node */
void UnregisterNodeSignals(CNodeSignals &nodeSignals);
/** Set inventory broadcasting delay time in seconds*/
bool SetInvBroadcastDelay(const int64_t& nDelay);
bool SetInvBroadcastDelay(const int64_t& nDelayMillisecs);

class PeerLogicValidation : public CValidationInterface {
private:
Expand Down
2 changes: 1 addition & 1 deletion test/functional/bsv-broadcast_delay.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class BroadcastDelayTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 2
self._nbSecondDelay = 10
self._fixedDelayArgs = [['-broadcastdelay={}'.format(1000000*self._nbSecondDelay)], ['-broadcastdelay={}'.format(1000000*self._nbSecondDelay)]]
self._fixedDelayArgs = [['-broadcastdelay={}'.format(1000*self._nbSecondDelay)], ['-broadcastdelay={}'.format(1000*self._nbSecondDelay)]]
self.nbTransTest = 3 ## Increase the number of transactions to test will increase the test quality

def setup_network(self):
Expand Down

0 comments on commit a9326c7

Please sign in to comment.