-
Notifications
You must be signed in to change notification settings - Fork 38.7k
refactoring: add a method for determining if a block is pruned or not #13259
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
5887dca to
e340c9c
Compare
src/rest.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.
Missing paren.
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.
Heh. Fixed.
e340c9c to
87a4c78
Compare
|
This is a different change but for simplification IMO there's room for a |
|
Not sure |
|
Unsure. I'm worries about the readability of the code as well as undetected |
|
@jonasschnelli The code that is replaced has to do that check already (null block index), so not sure what the concern is. Also, I think this helps with readability. I think the "is this block pruned? Oh let's just throw in a |
|
If you insist on factoring this out, I'd prefer an inline function instead of a macro. Macros are mostly an ugly C legacy (and have some well-known issues, such as that |
87a4c78 to
a0e2648
Compare
|
I'm not insisting anything, but I think it would help readability since the copy-pasted if case is rather hairy. Replaced macro with an inline method in |
|
Concept ACK: |
|
Concept ACK. I would leave the fHavePruned check at the call sites though for separation of concerns. |
|
@Empact I think it's okay to leave it in. It has very small impact and I think it's fine even if people check |
|
utACK a0e2648 |
|
utACK a0e2648. |
src/chain.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.
Adding this to the chain module introduces a cyclic dependency between chain and validation (as fHavePruned is defined there). There's no need for this to be a CBlockIndex member as it only uses public fields, so I would suggest making it a function in validation instead.
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.
Good point. I moved it (back) to validation.h.
5d6f03d to
0f80c21
Compare
src/validation.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.
nit, { on newline.
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.
Fixed.
0f80c21 to
dff0cf5
Compare
|
utACK dff0cf5 |
|
Needs rebase. |
dff0cf5 to
e9a1881
Compare
|
Rebased. |
|
nit: |
|
Also occurs to me that |
|
That sounds like a good idea, but it means having to make |
… pruned or not e9a1881 refactor: add a function for determining if a block is pruned or not (Karl-Johan Alm) Pull request description: The check for whether a block is pruned or not is sufficiently obscure that it deserves a macro. It is also used in 2 places, ~~with more coming, e.g. #10757~~ (turns out it was a move, not an addition). Tree-SHA512: b9aeb60663e1d1196df5371d5aa00b32ff5d4cdea6a77e4b566f28115cce09570c18e45e4b81a4033f67c4135c8e32c027f67bae3b75c2ea4564285578a3f4dd
Summary: "The check for whether a block is pruned or not is sufficiently obscure that it deserves a macro. It is also used in 2 places, ~~with more coming, e.g. #10757~~ (turns out it was a move, not an addition)." This is a backport from Core PR13259: bitcoin/bitcoin#13259 Test Plan: ninja check ./test/functional/test_runner.py Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix, nakihito, jasonbcox Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix, nakihito, jasonbcox Subscribers: jasonbcox Differential Revision: https://reviews.bitcoinabc.org/D4624
…lock is pruned or not e9a1881 refactor: add a function for determining if a block is pruned or not (Karl-Johan Alm) Pull request description: The check for whether a block is pruned or not is sufficiently obscure that it deserves a macro. It is also used in 2 places, ~~with more coming, e.g. bitcoin#10757~~ (turns out it was a move, not an addition). Tree-SHA512: b9aeb60663e1d1196df5371d5aa00b32ff5d4cdea6a77e4b566f28115cce09570c18e45e4b81a4033f67c4135c8e32c027f67bae3b75c2ea4564285578a3f4dd
Summary: "The check for whether a block is pruned or not is sufficiently obscure that it deserves a macro. It is also used in 2 places, ~~with more coming, e.g. #10757~~ (turns out it was a move, not an addition)." This is a backport from Core PR13259: bitcoin/bitcoin#13259 Test Plan: ninja check ./test/functional/test_runner.py Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix, nakihito, jasonbcox Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix, nakihito, jasonbcox Subscribers: jasonbcox Differential Revision: https://reviews.bitcoinabc.org/D4624
Summary: "The check for whether a block is pruned or not is sufficiently obscure that it deserves a macro. It is also used in 2 places, ~~with more coming, e.g. #10757~~ (turns out it was a move, not an addition)." This is a backport from Core PR13259: bitcoin/bitcoin#13259 Test Plan: ninja check ./test/functional/test_runner.py Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix, nakihito, jasonbcox Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix, nakihito, jasonbcox Subscribers: jasonbcox Differential Revision: https://reviews.bitcoinabc.org/D4624
Summary: "The check for whether a block is pruned or not is sufficiently obscure that it deserves a macro. It is also used in 2 places, ~~with more coming, e.g. #10757~~ (turns out it was a move, not an addition)." This is a backport from Core PR13259: bitcoin/bitcoin#13259 Test Plan: ninja check ./test/functional/test_runner.py Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix, nakihito, jasonbcox Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix, nakihito, jasonbcox Subscribers: jasonbcox Differential Revision: https://reviews.bitcoinabc.org/D4624
The check for whether a block is pruned or not is sufficiently obscure that it deserves a macro. It is also used in 2 places,
with more coming, e.g. #10757(turns out it was a move, not an addition).