-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Add LookupBlockIndex #11041
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
Add LookupBlockIndex #11041
Conversation
63e918e to
171213c
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.
!pblockindex
src/rpc/blockchain.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.
Same as above.
src/rpc/blockchain.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.
Remove assert.
fb505b2 to
51d4607
Compare
|
Concept ACK |
|
This may make #10692 a bit simpler, though I'm not sure it matters what order they come in. |
930b525 to
c515391
Compare
|
Fixed bug and rebased. |
|
@laanwj I believe it's ready. |
|
Concept ACK |
meshcollider
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.
utACK
src/net_processing.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.
Maybe explicit cast to bool here for clarity
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.
Prefer this?
return LookupBlockIndex(inv.hash) != nullptr;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.
Yeah or a ternary or even an if statement would be a lot clearer
c515391 to
1d1768f
Compare
|
Rebased and fixed @meshcollider comment. |
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.
Missing assert lock is held.
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 EXCLUSIVE_LOCKS_REQUIRED(cs_main) too :-)
ryanofsky
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.
utACK 1d1768f2978bafaf166bfa218c899ddaeeccad2d
src/wallet/wallet.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.
In some of these places you could do
if (const CBlockIndex* pindex = LookupBlockIndex(wtx.hashBlock))to reduce the scope of the pindex variables.
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.
I didn't know you could declare inside an if statement. Cool.
|
Thanks @ryanofsky, I have to rebase and then I'll take into account your comment above. |
8337539 to
a029cd4
Compare
jimpo
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. This is much cleaner.
src/init.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.
Need to keep the !mapBlockIndex.empty().
src/net_processing.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.
Needs a !
|
This needs rebase. I can do it and adapt the new code if there is interest in merging it quick. Maybe it should also make |
|
Concept ACK. Would like to see this rebased sooner rather than later. |
a029cd4 to
6d9f555
Compare
|
Forgot to tackle @ryanofsky comment above.. |
6d9f555 to
e741b98
Compare
|
travis failure: |
zcash: cherry picked from commit 02de6a6 zcash: bitcoin/bitcoin#11041
zcash: cherry picked from commit c651df8 zcash: bitcoin/bitcoin#11041
When accessing mapBlockIndex cs_main must be held. zcash: cherry picked from commit f814a3e zcash: bitcoin/bitcoin#11041
zcash: cherry picked from commit 43a32b7 zcash: bitcoin/bitcoin#11041
|
@promag What's the reason for avoiding mapBlockIndex lookups? |
|
@rebroad it avoids duplicate lookups - its unnecessary work. |
zcash: cherry picked from commit 02de6a6 zcash: bitcoin/bitcoin#11041
zcash: cherry picked from commit c651df8 zcash: bitcoin/bitcoin#11041
When accessing mapBlockIndex cs_main must be held. zcash: cherry picked from commit f814a3e zcash: bitcoin/bitcoin#11041
zcash: cherry picked from commit 43a32b7 zcash: bitcoin/bitcoin#11041
Contains both the changes done upstream and changes done in Dash codebase Signed-off-by: pasta <[email protected]>
…OCKORDER 33eb907 Fix ComputeTimeSmart test failure with -DDEBUG_LOCKORDER (Russell Yanofsky) Pull request description: Failure looks like: ``` Entering test case "ComputeTimeSmart" test_bitcoin: sync.cpp:100: void potential_deadlock_detected(const std::pair<void*, void*>&, const LockStack&, const LockStack&): Assertion `false' failed. unknown location(0): fatal error in "ComputeTimeSmart": signal: SIGABRT (application abort requested) wallet/test/wallet_tests.cpp(566): last checkpoint ``` Reproducible with: ``` ./configure --enable-debug make -C src test/test_bitcoin && src/test/test_bitcoin --log_level=test_suite --run_test=wallet_tests/ComputeTimeSmart ``` Seems to be caused by acquiring `cs_main` inside `CWallet::ComputeTimeSmart` in bitcoin#11041. I think this may be causing timeouts on travis like: https://travis-ci.org/bitcoin/bitcoin/jobs/353005676#L2692 Tree-SHA512: b263cd122ea9c88204d1d8e7e35291c71ea6319f05114c5009235a75dbd0f669bc0394f44afeed0d9eb08c2a956cd7c08f1ac4ef28616932fef9b43eaac5521b
Replace all
mapBlockIndexlookups with the newLookupBlockIndex(). In some cases it avoids a second lookup.