BIP155 (addrv2)

Tor v3 + i2p
This commit is contained in:
zanzibar
2023-01-06 15:21:08 +00:00
parent fe9f1ef9e4
commit 512da314a5
108 changed files with 8214 additions and 2173 deletions

View File

@@ -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;
}