-
Notifications
You must be signed in to change notification settings - Fork 1.2k
backport: make adjusted time type-safe (bitcoin#25786) #7459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -219,15 +219,17 @@ class CCoinJoinQueue | |
|
|
||
| CCoinJoinQueue() = default; | ||
|
|
||
| CCoinJoinQueue(int nDenom, const COutPoint& outpoint, const uint256& proTxHash, int64_t nTime, bool fReady) : | ||
| CCoinJoinQueue(int nDenom, const COutPoint& outpoint, const uint256& proTxHash, NodeClock::time_point time, bool fReady) : | ||
| nDenom(nDenom), | ||
| masternodeOutpoint(outpoint), | ||
| m_protxHash(proTxHash), | ||
| nTime(nTime), | ||
| nTime(TicksSinceEpoch<std::chrono::seconds>(time)), | ||
| fReady(fReady) | ||
| { | ||
| } | ||
|
|
||
| NodeSeconds Time() const { return NodeSeconds{std::chrono::seconds{nTime}}; } | ||
|
|
||
| SERIALIZE_METHODS(CCoinJoinQueue, obj) | ||
| { | ||
| READWRITE(obj.nDenom, obj.m_protxHash, obj.nTime, obj.fReady); | ||
|
|
@@ -243,7 +245,8 @@ class CCoinJoinQueue | |
| [[nodiscard]] bool CheckSignature(const CBLSPublicKey& blsPubKey) const; | ||
|
|
||
| /// Check if a queue is too old or too far into the future | ||
| [[nodiscard]] bool IsTimeOutOfBounds(int64_t current_time = GetAdjustedTime()) const; | ||
| [[nodiscard]] bool IsTimeOutOfBounds(NodeSeconds current_time) const; | ||
| [[nodiscard]] bool IsTimeOutOfBounds() const; | ||
|
Comment on lines
+248
to
+249
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2 methods with the same name is a bit strange too. consider renaming one from
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's for the overload? |
||
|
|
||
| [[nodiscard]] std::string ToString() const; | ||
|
|
||
|
|
@@ -273,11 +276,11 @@ class CCoinJoinBroadcastTx | |
| { | ||
| } | ||
|
|
||
| CCoinJoinBroadcastTx(CTransactionRef _tx, const COutPoint& _outpoint, const uint256& proTxHash, int64_t _sigTime) : | ||
| CCoinJoinBroadcastTx(CTransactionRef _tx, const COutPoint& _outpoint, const uint256& proTxHash, NodeClock::time_point time) : | ||
| tx(std::move(_tx)), | ||
| masternodeOutpoint(_outpoint), | ||
| m_protxHash(proTxHash), | ||
| sigTime(_sigTime) | ||
| sigTime(TicksSinceEpoch<std::chrono::seconds>(time)) | ||
| { | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: technically, it's valid code, but looks a bit strange without 0s