Dash Core  0.12.2.1
P2P Digital Currency
utiltime.cpp File Reference
#include "tinyformat.h"
#include "utiltime.h"
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/thread.hpp>

Go to the source code of this file.

Functions

int64_t GetTime ()
 For unit testing. More...
 
void SetMockTime (int64_t nMockTimeIn)
 
int64_t GetTimeMillis ()
 
int64_t GetTimeMicros ()
 
int64_t GetSystemTimeInSeconds ()
 
int64_t GetLogTimeMicros ()
 
void MilliSleep (int64_t n)
 
std::string DateTimeStrFormat (const char *pszFormat, int64_t nTime)
 
std::string DurationToDHMS (int64_t nDurationTime)
 

Variables

static int64_t nMockTime = 0
 

Function Documentation

◆ DateTimeStrFormat()

◆ DurationToDHMS()

std::string DurationToDHMS ( int64_t  nDurationTime)

◆ GetLogTimeMicros()

int64_t GetLogTimeMicros ( )

Return a time useful for the debug log

Definition at line 56 of file utiltime.cpp.

Referenced by LogTimestampStr().

◆ GetSystemTimeInSeconds()

int64_t GetSystemTimeInSeconds ( )

◆ GetTime()

int64_t GetTime ( )

For unit testing.

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).

Definition at line 20 of file utiltime.cpp.

Referenced by CTxMemPool::_clear(), AcceptToMemoryPoolWorker(), CNetFulfilledRequestManager::AddFulfilledRequest(), AppInit2(), CNode::AskFor(), CMasternodeMan::AskForMN(), AutoBackupWallet(), CConnman::Ban(), BitcoinMiner(), CMasternodeSync::BumpAssetLastTime(), CMasternode::Check(), CNetFulfilledRequestManager::CheckAndRemove(), CInstantSend::CheckAndRemove(), CMasternodeMan::CheckAndRemove(), CheckBlock(), CMasternodeMan::CheckMnbAndUpdateMasternodeList(), CKeyPool::CKeyPool(), ConnectBlock(), convertSeed6(), CWalletKey::CWalletKey(), CMasternodeMan::DsegUpdate(), dumpwallet(), CSporkManager::ExecuteSpork(), CMasternodeSync::Fail(), CWallet::GenerateNewKey(), GetAdjustedTime(), getblocktemplate(), CConnman::GetMaxOutboundTimeLeftInCycle(), CTxMemPool::GetMinFee(), CWallet::GetOldestKeyPoolTime(), gobject(), CNetFulfilledRequestManager::HasFulfilledRequest(), CConnman::IsBanned(), CTxLockVote::IsFailed(), IsInitialBlockDownload(), CTxLockVote::IsTimedOut(), CTxLockCandidate::IsTimedOut(), CMasternodeMan::IsWatchdogActive(), LimitMempoolSize(), MasternodeList::MasternodeList(), CGovernanceManager::MasternodeRateUpdate(), CPrivateSendClient::NewBlock(), MasternodeList::on_filterLineEdit_textChanged(), CMasternodeMan::ProcessMessage(), ProcessMessage(), CMasternodeSync::ProcessTick(), CInstantSend::ProcessTxLockVote(), RandAddSeedPerfmon(), CConnman::RecordBytesSent(), CWalletDB::Recover(), RelayAddress(), CConnman::RelayTransaction(), CTxMemPool::removeForBlock(), ReprocessBlocks(), CGovernanceManager::RequestGovernanceObjectVotes(), CWallet::ResendWalletTransactions(), resendwallettransactions(), CMasternodeSync::Reset(), CWallet::ScanForWalletTransactions(), CConnman::SetMaxOutboundTimeframe(), CConnman::SweepBanned(), CMasternodeSync::SwitchToNextAsset(), CConnman::ThreadDNSAddressSeed(), ThreadFlushWalletDB(), CConnman::ThreadOpenConnections(), BitcoinGUI::updateHeadersSyncProgressLabel(), CMasternodeMan::UpdateMasternodeList(), MasternodeList::updateMyNodeList(), MasternodeList::updateNodeList(), CMasternodeMan::UpdateWatchdogVoteTime(), CWallet::Verify(), PaymentServer::verifyExpired(), and walletpassphrase().

◆ GetTimeMicros()

◆ GetTimeMillis()

◆ MilliSleep()

void MilliSleep ( int64_t  n)

Boost's sleep_for was uninterruptable when backed by nanosleep from 1.50 until fixed in 1.52. Use the deprecated sleep method for the broken case. See: https://svn.boost.org/trac/boost/ticket/7238

Definition at line 63 of file utiltime.cpp.

Referenced by AppInit2(), BackupWallet(), BitcoinMiner(), CommandLineRPC(), HTTPReq_JSONRPC(), CDB::Rewrite(), Sleep100ms(), ThreadCheckPrivateSend(), ThreadCheckPrivateSendClient(), ThreadCheckPrivateSendServer(), ThreadFlushWalletDB(), ThreadSendAlert(), CPrivateSendClient::UnlockCoins(), and WaitForShutdown().

◆ SetMockTime()

void SetMockTime ( int64_t  nMockTimeIn)

Definition at line 29 of file utiltime.cpp.

Referenced by AppInit2(), and setmocktime().

Variable Documentation

◆ nMockTime

int64_t nMockTime = 0
static

Definition at line 18 of file utiltime.cpp.

Referenced by GetLogTimeMicros(), GetTime(), and SetMockTime().