Apply suggestions from code review
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
parent
88401bc25e
commit
825ca45341
|
@ -1241,14 +1241,16 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||
fAlerts = GetBoolArg("-alerts", DEFAULT_ALERTS);
|
||||
|
||||
// Option to startup with mocktime set (used for regression testing);
|
||||
// an mocktime of 0 (the default) selects the system clock.
|
||||
// a mocktime of 0 (the default) selects the system clock.
|
||||
int64_t nMockTime = GetArg("-mocktime", 0);
|
||||
if (nMockTime != 0) {
|
||||
int64_t nOffsetTime = GetArg("-clockoffset", 0);
|
||||
if (nMockTime != 0 && nOffsetTime != 0) {
|
||||
return InitError(_("-mocktime and -clockoffset cannot be used together"));
|
||||
} else if (nMockTime != 0) {
|
||||
FixedClock::SetGlobal(nMockTime);
|
||||
} else {
|
||||
// Option to start a node with the system clock offset by a constant
|
||||
// value throughout the life of the node (used for regression testing):
|
||||
int64_t nOffsetTime = GetArg("-clockoffset", 0);
|
||||
OffsetClock::SetGlobal(nOffsetTime);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
RecursiveMutex clock_lock;
|
||||
RecursiveMutex cs_clock;
|
||||
static CClock* zcashdClock = SystemClock::Instance();
|
||||
|
||||
void SystemClock::SetGlobal() {
|
||||
LOCK(clock_lock);
|
||||
LOCK(cs_clock);
|
||||
zcashdClock = SystemClock::Instance();
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ int64_t SystemClock::GetTimeMicros() const {
|
|||
}
|
||||
|
||||
void FixedClock::SetGlobal(int64_t nFixedTime) {
|
||||
LOCK(clock_lock);
|
||||
LOCK(cs_clock);
|
||||
FixedClock::Instance()->Set(nFixedTime);
|
||||
zcashdClock = FixedClock::Instance();
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ int64_t FixedClock::GetTimeMicros() const {
|
|||
OffsetClock OffsetClock::instance;
|
||||
|
||||
void OffsetClock::SetGlobal(int64_t nOffsetSeconds) {
|
||||
LOCK(clock_lock);
|
||||
LOCK(cs_clock);
|
||||
OffsetClock::Instance()->Set(nOffsetSeconds);
|
||||
zcashdClock = OffsetClock::Instance();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue