BIP155 (addrv2)
Tor v3 + i2p
This commit is contained in:
@@ -25,6 +25,21 @@ int64_t GetTime()
|
||||
return time(NULL);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T GetTime()
|
||||
{
|
||||
const std::chrono::seconds mocktime{nMockTime};
|
||||
|
||||
return std::chrono::duration_cast<T>(
|
||||
mocktime.count() ?
|
||||
mocktime :
|
||||
std::chrono::microseconds{GetTimeMicros()});
|
||||
}
|
||||
template std::chrono::seconds GetTime();
|
||||
template std::chrono::milliseconds GetTime();
|
||||
template std::chrono::microseconds GetTime();
|
||||
|
||||
|
||||
void SetMockTime(int64_t nMockTimeIn)
|
||||
{
|
||||
nMockTime = nMockTimeIn;
|
||||
@@ -42,6 +57,11 @@ int64_t GetTimeMicros()
|
||||
std::chrono::system_clock::now().time_since_epoch()).count();
|
||||
}
|
||||
|
||||
int64_t GetSystemTimeInSeconds()
|
||||
{
|
||||
return GetTimeMicros()/1000000;
|
||||
}
|
||||
|
||||
void MilliSleep(int64_t n)
|
||||
{
|
||||
boost::this_thread::sleep_for(boost::chrono::milliseconds(n));
|
||||
@@ -56,3 +76,11 @@ std::string DateTimeStrFormat(const char* pszFormat, int64_t nTime)
|
||||
ss << boost::posix_time::from_time_t(nTime);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
struct timeval MillisToTimeval(int64_t nTimeout)
|
||||
{
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = nTimeout / 1000;
|
||||
timeout.tv_usec = (nTimeout % 1000) * 1000;
|
||||
return timeout;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user