-
Notifications
You must be signed in to change notification settings - Fork 37.7k
txmempool: Make entry time type-safe (std::chrono) #16908
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
Conversation
Concep ACK, |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
ConceptACK I think Having |
Also, remove the now unused "Mine a single block to get out of IBD". This was fixed in commit 1111aec.
fa05d99
to
fa18adc
Compare
Thx for the review. Took all suggestions by you. |
fa18adc
to
faec689
Compare
utACK faec689 |
@@ -1541,11 +1541,11 @@ void static ProcessGetData(CNode* pfrom, const CChainParams& chainparams, CConnm | |||
if (mi != mapRelay.end()) { | |||
connman->PushMessage(pfrom, msgMaker.Make(nSendFlags, NetMsgType::TX, *mi->second)); | |||
push = true; | |||
} else if (pfrom->m_tx_relay->timeLastMempoolReq) { | |||
} else if (pfrom->m_tx_relay->m_last_mempool_req.load().count()) { |
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.
why not use count_seconds
here, if it is preferred to inline .count()
(according to the comment)?
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.
The member uses a magic value of 0 to indicate that the mempool was never requested. So this check isn't about time (in a specific type like seconds), but more about checking that any value exists.
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.
Hmm, okay, I guess we'd really want a optional
here some day instead of a magic value, but no need to do that here.
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.
Sorry to chime in late -- would it make sense to use the std::chrono::duration::zero
value here? I found count()
to be unintuitive when I was looking at related code just now (but this std::chrono
stuff is new to me so I'm still figuring out how to use it).
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.
Comparing it to zero would also work, but still be odd, as the code is written as if the member were an optional
.
I think we can just stop treating it as optional
(always assume the last mempool request time for peers was in year 1970). But that can be done in a follow up pull request.
ACK faec689 |
faec689 txmempool: Make entry time type-safe (std::chrono) (MarcoFalke) faaa1f0 util: Add count_seconds time helper (MarcoFalke) 1111170 test: mempool entry time is persisted (MarcoFalke) Pull request description: This changes the type of the entry time of txs into the mempool from `int64_t` to `std::chrono::seconds`. The benefits: * Documents the type for developers * Type violations result in compile errors * After compilation, the two are equivalent (at no run time cost) ACKs for top commit: ajtowns: utACK faec689 laanwj: ACK faec689 Tree-SHA512: d958e058755d1a1d54cef536a8b30a11cc502b7df0d6ecf84a0ab1d38bc8105a67668a99cd5087a444f6de2421238111c5fca133cdf8e2e2273cb12cb6957845
faec689 txmempool: Make entry time type-safe (std::chrono) (MarcoFalke) faaa1f0 util: Add count_seconds time helper (MarcoFalke) 1111170 test: mempool entry time is persisted (MarcoFalke) Pull request description: This changes the type of the entry time of txs into the mempool from `int64_t` to `std::chrono::seconds`. The benefits: * Documents the type for developers * Type violations result in compile errors * After compilation, the two are equivalent (at no run time cost) ACKs for top commit: ajtowns: utACK faec689 laanwj: ACK faec689 Tree-SHA512: d958e058755d1a1d54cef536a8b30a11cc502b7df0d6ecf84a0ab1d38bc8105a67668a99cd5087a444f6de2421238111c5fca133cdf8e2e2273cb12cb6957845
Summary: Also, remove the now unused "Mine a single block to get out of IBD". This was fixed in commit 1111aecbb5. bitcoin/bitcoin@1111170 --- Depends on D6522 Partial backport of [[bitcoin/bitcoin#16908 | PR16908]] Test Plan: test_runner.py mempool_persist Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D6523
Summary: bitcoin/bitcoin@faaa1f0 --- Depends on D6523 Partial backport of Core [[bitcoin/bitcoin#16908 | PR16908]] Test Plan: ninja Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D6524
Summary: bitcoin/bitcoin@faec689 --- Depends on D6524 Concludes backport of Core [[bitcoin/bitcoin#16908 | PR16908]] Test Plan: ninja check-all Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D6527
merge bitcoin#16117, bitcoin#18358, bitcoin#17383, bitcoin#21052, bitcoin#14424, bitcoin#15159, bitcoin#14689, bitcoin#14978, partial bitcoin#16908, bitcoin#14978, bitcoin#13932: Auxillary Backports
This changes the type of the entry time of txs into the mempool from
int64_t
tostd::chrono::seconds
.The benefits: