Skip to content

Commit 9c1b91e

Browse files
committed
Additional changes for GetAdjustedTime
1 parent a657bf5 commit 9c1b91e

File tree

15 files changed

+31
-31
lines changed

15 files changed

+31
-31
lines changed

src/coinjoin/coinjoin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ class CCoinJoinQueue
212212
[[nodiscard]] bool CheckSignature(const CBLSPublicKey& blsPubKey) const;
213213

214214
/// Check if a queue is too old or too far into the future
215-
[[nodiscard]] bool IsTimeOutOfBounds(int64_t current_time = GetAdjustedTime()) const;
215+
[[nodiscard]] bool IsTimeOutOfBounds(int64_t current_time = TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime())) const;
216216

217217
[[nodiscard]] std::string ToString() const;
218218

src/coinjoin/server.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ void CCoinJoinServer::CommitFinalTransaction()
360360
// create and sign masternode dstx transaction
361361
if (!m_dstxman.GetDSTX(hashTx)) {
362362
CCoinJoinBroadcastTx dstxNew(finalTransaction, m_mn_activeman.GetOutPoint(), m_mn_activeman.GetProTxHash(),
363-
GetAdjustedTime());
363+
TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime()));
364364
dstxNew.vchSig = m_mn_activeman.SignBasic(dstxNew.GetSignatureHash());
365365
m_dstxman.AddDSTX(dstxNew);
366366
}
@@ -517,7 +517,7 @@ void CCoinJoinServer::CheckForCompleteQueue()
517517
SetState(POOL_STATE_ACCEPTING_ENTRIES);
518518

519519
CCoinJoinQueue dsq(nSessionDenom, m_mn_activeman.GetOutPoint(), m_mn_activeman.GetProTxHash(),
520-
GetAdjustedTime(), true);
520+
TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime()), true);
521521
LogPrint(BCLog::COINJOIN, "CCoinJoinServer::CheckForCompleteQueue -- queue is ready, signing and relaying (%s) " /* Continued */
522522
"with %d participants\n", dsq.ToString(), vecSessionCollaterals.size());
523523
dsq.vchSig = m_mn_activeman.SignBasic(dsq.GetSignatureHash());
@@ -728,7 +728,7 @@ bool CCoinJoinServer::CreateNewSession(const CCoinJoinAccept& dsa, PoolMessage&
728728
if (!fUnitTest) {
729729
//broadcast that I'm accepting entries, only if it's the first entry through
730730
CCoinJoinQueue dsq(nSessionDenom, m_mn_activeman.GetOutPoint(), m_mn_activeman.GetProTxHash(),
731-
GetAdjustedTime(), false);
731+
TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime()), false);
732732
LogPrint(BCLog::COINJOIN, "CCoinJoinServer::CreateNewSession -- signing and relaying new queue: %s\n", dsq.ToString());
733733
dsq.vchSig = m_mn_activeman.SignBasic(dsq.GetSignatureHash());
734734
m_peerman.RelayDSQ(dsq);

src/governance/governance.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ void CGovernanceManager::CheckOrphanVotes(CGovernanceObject& govobj)
371371

372372
ScopedLockBool guard(cs_store, fRateChecksEnabled, false);
373373

374-
int64_t nNow = GetAdjustedTime();
374+
int64_t nNow = TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime());
375375
const auto tip_mn_list = Assert(m_dmnman)->GetListAtChainTip();
376376
for (const auto& pairVote : vecVotePairs) {
377377
const auto& [vote, time] = pairVote;
@@ -860,7 +860,7 @@ bool CGovernanceManager::MasternodeRateCheck(const CGovernanceObject& govobj, bo
860860

861861
const COutPoint& masternodeOutpoint = govobj.GetMasternodeOutpoint();
862862
int64_t nTimestamp = govobj.GetCreationTime();
863-
int64_t nNow = GetAdjustedTime();
863+
int64_t nNow = TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime());
864864
int64_t nSuperblockCycleSeconds = Params().GetConsensus().nSuperblockCycle * Params().GetConsensus().nPowTargetSpacing;
865865

866866
std::string strHash = govobj.GetHash().ToString();
@@ -1014,7 +1014,7 @@ void CGovernanceManager::CheckPostponedObjects()
10141014

10151015

10161016
// Perform additional relays for triggers
1017-
int64_t nNow = GetAdjustedTime();
1017+
int64_t nNow = TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime());
10181018
int64_t nSuperblockCycleSeconds = Params().GetConsensus().nSuperblockCycle * Params().GetConsensus().nPowTargetSpacing;
10191019

10201020
for (auto it = setAdditionalRelayObjects.begin(); it != setAdditionalRelayObjects.end();) {

src/governance/object.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ bool CGovernanceObject::ProcessVote(CMasternodeMetaMan& mn_metaman, CGovernanceM
120120
LogPrint(BCLog::GOBJECT, "%s\n", msg);
121121
}
122122

123-
int64_t nNow = GetAdjustedTime();
123+
int64_t nNow = TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime());
124124
int64_t nVoteTimeUpdate = voteInstanceRef.nTime;
125125
if (govman.AreRateChecksEnabled()) {
126126
int64_t nTimeDelta = nNow - voteInstanceRef.nTime;

src/governance/signing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ std::optional<const CGovernanceObject> GovernanceSigner::CreateGovernanceTrigger
127127
LOCK(::cs_main);
128128

129129
// Check if identical trigger (equal DataHash()) is already created (signed by other masternode)
130-
CGovernanceObject gov_sb(uint256(), 1, GetAdjustedTime(), uint256(), sb_opt.value().GetHexStrData());
130+
CGovernanceObject gov_sb(uint256(), 1, TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime()), uint256(), sb_opt.value().GetHexStrData());
131131
if (auto identical_sb = m_govman.FindGovernanceObjectByDataHash(gov_sb.GetDataHash())) {
132132
// Somebody submitted a trigger with the same data, support it instead of submitting a duplicate
133133
return std::make_optional<CGovernanceObject>(*identical_sb);
@@ -261,7 +261,7 @@ void GovernanceSigner::VoteGovernanceTriggers(const std::optional<const CGoverna
261261
bool GovernanceSigner::VoteFundingTrigger(const uint256& nHash, const vote_outcome_enum_t outcome)
262262
{
263263
CGovernanceVote vote(m_mn_activeman.GetOutPoint(), nHash, VOTE_SIGNAL_FUNDING, outcome);
264-
vote.SetTime(GetAdjustedTime());
264+
vote.SetTime(TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime()));
265265
vote.SetSignature(m_mn_activeman.SignBasic(vote.GetSignatureHash()));
266266

267267
CGovernanceException exception;

src/governance/validators.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ bool CProposalValidator::ValidateStartEndEpoch(bool fCheckExpiration)
136136
return false;
137137
}
138138

139-
if (fCheckExpiration && nEndEpoch <= GetAdjustedTime()) {
139+
if (fCheckExpiration && nEndEpoch <= TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime())) {
140140
strErrorMessages += "expired;";
141141
return false;
142142
}

src/governance/vote.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ CGovernanceVote::CGovernanceVote(const COutPoint& outpointMasternodeIn, const ui
8787
nParentHash(nParentHashIn),
8888
nVoteOutcome(eVoteOutcomeIn),
8989
nVoteSignal(eVoteSignalIn),
90-
nTime(GetAdjustedTime())
90+
nTime(TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime()))
9191
{
9292
UpdateHash();
9393
}
@@ -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 > 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, GetAdjustedTime() + (60 * 60));
157+
if (nTime > TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime() + 1h)) {
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() + 1h));
159159
return false;
160160
}
161161

src/llmq/debug.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ void CDKGDebugManager::ResetLocalSessionStatus(Consensus::LLMQType llmqType, int
154154
}
155155

156156
localStatus.sessions.erase(it);
157-
localStatus.nTime = GetAdjustedTime();
157+
localStatus.nTime = TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime());
158158
}
159159

160160
void CDKGDebugManager::InitLocalSessionStatus(const Consensus::LLMQParams& llmqParams, int quorumIndex, const uint256& quorumHash, int quorumHeight)
@@ -186,7 +186,7 @@ void CDKGDebugManager::UpdateLocalSessionStatus(Consensus::LLMQType llmqType, in
186186
}
187187

188188
if (func(it->second)) {
189-
localStatus.nTime = GetAdjustedTime();
189+
localStatus.nTime = TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime());
190190
}
191191
}
192192

@@ -200,7 +200,7 @@ void CDKGDebugManager::UpdateLocalMemberStatus(Consensus::LLMQType llmqType, int
200200
}
201201

202202
if (func(it->second.members.at(memberIdx))) {
203-
localStatus.nTime = GetAdjustedTime();
203+
localStatus.nTime = TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime());
204204
}
205205
}
206206

src/net_processing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6025,7 +6025,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
60256025
// Convert HEADERS_DOWNLOAD_TIMEOUT_PER_HEADER to microseconds before scaling
60266026
// to maintain precision
60276027
std::chrono::microseconds{HEADERS_DOWNLOAD_TIMEOUT_PER_HEADER} *
6028-
Ticks<std::chrono::seconds>(GetAdjustedTime() - m_chainman.m_best_header->Time()) / consensusParams.nPowTargetSpacing
6028+
Ticks<std::chrono::seconds>(TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime() - m_chainman.m_best_header->Time())) / consensusParams.nPowTargetSpacing
60296029
);
60306030
nSyncStarted++;
60316031
}

src/rpc/governance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static RPCHelpMan gobject_check()
124124

125125
int nRevision = 1;
126126

127-
int64_t nTime = GetAdjustedTime();
127+
int64_t nTime = TicksSinceEpoch<std::chrono::seconds>(GetAdjustedTime());
128128
std::string strDataHex = request.params[0].get_str();
129129

130130
CGovernanceObject govobj(hashParent, nRevision, nTime, uint256(), strDataHex);

0 commit comments

Comments
 (0)