aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/misc.cpp
diff options
context:
space:
mode:
authorSuhas Daftuar <sdaftuar@gmail.com>2017-01-19 13:01:18 -0500
committerSuhas Daftuar <sdaftuar@gmail.com>2017-01-25 09:48:14 -0500
commit99464bc38e9575ff47f8e33223b252dcea2055e3 (patch)
tree8b01122ab862afac1470e86d0a780780329250d7 /src/rpc/misc.cpp
parent054d664215ca8d5f17d8aadbfc5b78a8dcd5115c (diff)
downloadbitcoin-99464bc38e9575ff47f8e33223b252dcea2055e3.tar.xz
net: Consistently use GetTimeMicros() for inactivity checks
The use of mocktime in test logic means that comparisons between GetTime() and GetTimeMicros()/1000000 are unreliable since the former can use mocktime values while the latter always gets the system clock; this changes the networking code's inactivity checks to consistently use the system clock for inactivity comparisons. Also remove some hacks from setmocktime() that are no longer needed, now that we're using the system clock for nLastSend and nLastRecv.
Diffstat (limited to 'src/rpc/misc.cpp')
-rw-r--r--src/rpc/misc.cpp16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp
index 54d8c3e035..480c45516c 100644
--- a/src/rpc/misc.cpp
+++ b/src/rpc/misc.cpp
@@ -431,22 +431,16 @@ UniValue setmocktime(const JSONRPCRequest& request)
if (!Params().MineBlocksOnDemand())
throw runtime_error("setmocktime for regression testing (-regtest mode) only");
- // cs_vNodes is locked and node send/receive times are updated
- // atomically with the time change to prevent peers from being
- // disconnected because we think we haven't communicated with them
- // in a long time.
+ // For now, don't change mocktime if we're in the middle of validation, as
+ // this could have an effect on mempool time-based eviction, as well as
+ // IsCurrentForFeeEstimation() and IsInitialBlockDownload().
+ // TODO: figure out the right way to synchronize around mocktime, and
+ // ensure all callsites of GetTime() are accessing this safely.
LOCK(cs_main);
RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VNUM));
SetMockTime(request.params[0].get_int64());
- uint64_t t = GetTime();
- if(g_connman) {
- g_connman->ForEachNode([t](CNode* pnode) {
- pnode->nLastSend = pnode->nLastRecv = t;
- });
- }
-
return NullUniValue;
}