-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Introduce MempoolObserver interface to break "policy/fees -> txmempool -> policy/fees" circular dependency #13949
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
45ef07c to
2a44b30
Compare
|
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. |
|
Concept ACK Thanks for working on these circular dependencies! |
l2a5b1
left a 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.
Concept ACK. Thanks @Empact!
src/policy/fees.h
Outdated
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.
You can mark the declarations of interfaces::MempoolObserver methods in CBlockPolicyEstimator with override:
void processBlock(unsigned int nBlockHeight,
std::vector<const CTxMemPoolEntry*>& entries) override;
void processTransaction(const CTxMemPoolEntry& entry, bool validFeeEstimate) override;
bool removeTx(uint256 hash) override;
src/policy/fees.h
Outdated
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.
To prevent redundant documentation, maybe you can declare the interfaces::MempoolObserver methods in CBlockPolicyEstimator without copying the documentation from the method declarations in interfaces::MempoolObserver.
void processBlock(unsigned int nBlockHeight,
std::vector<const CTxMemPoolEntry*>& entries);
void processTransaction(const CTxMemPoolEntry& entry, bool validFeeEstimate);
/**
* Removal is not inBlock as in-block removals are handled internally.
*/
bool removeTx(uint256 hash);2a44b30 to
2ec0a07
Compare
|
Marked methods |
2ec0a07 to
56ec018
Compare
|
Made the |
|
utACK 56ec018 when squashed. One nit: I was wondering about the location of |
d8c390b to
7b31ea2
Compare
|
Thanks for calling out the readme. Fixed, rebased, and squashed. |
7b31ea2 to
f58e17e
Compare
|
yw, nice refactor! utACK f58e17e |
src/policy/fees.cpp
Outdated
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.
hash should be passed by const reference?
f58e17e to
e44968a
Compare
|
Changed |
|
copy-paste from #15638 (comment) by @ryanofsky: While I think in some cases fixing An example would be the circular dependency between The simple and obvious way to write this code is to declare the mempool entry struct in
It's possible changes like these would be good for other reasons, but in general I think cleaning up spew from |
|
re: #13949 (comment) Wow, I didn't know about (or maybe forgot about?) this PR. Looking over this change, it may not be a bad idea if there are justifications for it other than fixing circular dependencies. In the pasted comment, I was actually complaining circular dependency errors in the context of #10443, not this PR. |
|
This refactoring change is +80-17. Generally I'd prefer if refactoring simplified things, not made them harder |
e87926c to
8501bdc
Compare
|
Now +70 −16, with +43 coming from the interface header itself. I would argue this does make things simpler, by making A practical benefit is that this makes |
|
utACK 8501bdc. The introduction of the |
This is an abstract interface which presents removes the dependency between CBlockPolicyEstimator and CTxMemPool
| Needs rebase |
|
Closing in favor of #17786 |
A simple interface which make the implementations independent of one another.
Note I also removed the
inBlockargument to the publicCBlockPolicyEstimator::removeTx, as all block-related removal calls are internal to the class. This simplifies the extracted interface and reduces CBlockPolicyEstimator surface area.