aboutsummaryrefslogtreecommitdiff
path: root/src/utiltime.h
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/utiltime.h
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/utiltime.h')
-rw-r--r--src/utiltime.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/utiltime.h b/src/utiltime.h
index b2807267db..05c6790495 100644
--- a/src/utiltime.h
+++ b/src/utiltime.h
@@ -9,9 +9,20 @@
#include <stdint.h>
#include <string>
+/**
+ * GetTimeMicros() and GetTimeMillis() both return the system time, but in
+ * different units. GetTime() returns the sytem time in seconds, but also
+ * supports mocktime, where the time can be specified by the user, eg for
+ * testing (eg with the setmocktime rpc, or -mocktime argument).
+ *
+ * TODO: Rework these functions to be type-safe (so that we don't inadvertently
+ * compare numbers with different units, or compare a mocktime to system time).
+ */
+
int64_t GetTime();
int64_t GetTimeMillis();
int64_t GetTimeMicros();
+int64_t GetSystemTimeInSeconds(); // Like GetTime(), but not mockable
int64_t GetLogTimeMicros();
void SetMockTime(int64_t nMockTimeIn);
void MilliSleep(int64_t n);