Skip to content

Commit b58d811

Browse files
committed
Additional changes for GetAdjustedTime 1
1 parent 908fa07 commit b58d811

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/governance/vote.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ bool CGovernanceVote::CheckSignature(const CBLSPublicKey& pubKey) const
154154

155155
bool CGovernanceVote::IsValid(const CDeterministicMNList& tip_mn_list, bool useVotingKey) const
156156
{
157-
if (nTime > TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime()) + (60 * 60)) {
158-
LogPrint(BCLog::GOBJECT, "CGovernanceVote::IsValid -- vote is too far ahead of current time - %s - nTime %lli - Max Time %lli\n", GetHash().ToString(), nTime, TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime()) + (60 * 60));
157+
if (nTime > TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime() + (60 * 60))) {
158+
LogPrint(BCLog::GOBJECT, "CGovernanceVote::IsValid -- vote is too far ahead of current time - %s - nTime %lli - Max Time %lli\n", GetHash().ToString(), nTime, TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime() + (60 * 60)));
159159
return false;
160160
}
161161

src/net_processing.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,7 @@ bool PeerManagerImpl::TipMayBeStale()
13511351

13521352
bool PeerManagerImpl::CanDirectFetch()
13531353
{
1354-
return m_chainman.ActiveChain().Tip()->Time() > TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime()) - m_chainparams.GetConsensus().PowTargetSpacing() * 20;
1354+
return m_chainman.ActiveChain().Tip()->Time() > GetAdjustedTime() - m_chainparams.GetConsensus().PowTargetSpacing() * 20;
13551355
}
13561356

13571357
static bool PeerHasHeader(CNodeState *state, const CBlockIndex *pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
@@ -6003,7 +6003,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
60036003

60046004
if (!state.fSyncStarted && CanServeBlocks(*peer) && !fImporting && !fReindex && pto->CanRelay()) {
60056005
// Only actively request headers from a single peer, unless we're close to end of initial download.
6006-
if ((nSyncStarted == 0 && sync_blocks_and_headers_from_peer) || m_chainman.m_best_header->Time() > TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime()) - 24h) {
6006+
if ((nSyncStarted == 0 && sync_blocks_and_headers_from_peer) || m_chainman.m_best_header->Time() > GetAdjustedTime() - 24h) {
60076007
const CBlockIndex* pindexStart = m_chainman.m_best_header;
60086008
/* If possible, start at the block preceding the currently
60096009
best known header. This ensures that we always get a
@@ -6024,7 +6024,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
60246024
// Convert HEADERS_DOWNLOAD_TIMEOUT_PER_HEADER to microseconds before scaling
60256025
// to maintain precision
60266026
std::chrono::microseconds{HEADERS_DOWNLOAD_TIMEOUT_PER_HEADER} *
6027-
Ticks<std::chrono::seconds>(TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime()) - m_chainman.m_best_header->Time()) / consensusParams.nPowTargetSpacing
6027+
Ticks<std::chrono::seconds>(TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime() - m_chainman.m_best_header->Time())) / consensusParams.nPowTargetSpacing
60286028
);
60296029
nSyncStarted++;
60306030
}
@@ -6406,7 +6406,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
64066406
// Check for headers sync timeouts
64076407
if (state.fSyncStarted && state.m_headers_sync_timeout < std::chrono::microseconds::max()) {
64086408
// Detect whether this is a stalling initial-headers-sync peer
6409-
if (m_chainman.m_best_header->Time() <= TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime()) - 24h) {
6409+
if (m_chainman.m_best_header->Time() <= GetAdjustedTime() - 24h) {
64106410
if (current_time > state.m_headers_sync_timeout && nSyncStarted == 1 && (m_num_preferred_download_peers - state.fPreferredDownload >= 1)) {
64116411
// Disconnect a peer (without NetPermissionFlags::NoBan permission) if it is our only sync peer,
64126412
// and we have others we could be using instead.

src/spork.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ MessageProcessingResult CSporkManager::ProcessSpork(NodeId from, CDataStream& vR
145145
MessageProcessingResult ret{};
146146
ret.m_to_erase = CInv{MSG_SPORK, hash};
147147

148-
if (spork.nTimeSigned > TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime()) + 2 * 60 * 60) {
148+
if (spork.nTimeSigned > TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime() + 2 * 60 * 60)) {
149149
LogPrint(BCLog::SPORK, "CSporkManager::ProcessSpork -- ERROR: too far into the future\n");
150150
ret.m_error = MisbehavingError{100};
151151
return ret;

0 commit comments

Comments
 (0)