Page MenuHomePhabricator

Merge #11041: Add LookupBlockIndex
ClosedPublic

Authored by jasonbcox on Wed, Apr 10, 17:46.

Details

Reviewers
deadalnix
Fabien
Group Reviewers
Restricted Project
Commits
rABC60d8a7a5a5ed: Merge #11041: Add LookupBlockIndex
Summary

92fabcd44 Add LookupBlockIndex function (João Barbosa)
43a32b739 Add missing cs_lock in CreateWalletFromFile (João Barbosa)
f814a3e8f Fix cs_main lock in LoadExternalBlockFile (João Barbosa)
c651df8b3 Lock cs_main while loading block index in AppInitMain (João Barbosa)
02de6a6bc Assert cs_main is held when accessing mapBlockIndex (João Barbosa)

Pull request description:

Replace all `mapBlockIndex` lookups with the new `LookupBlockIndex()`. In some cases it avoids a second lookup.

Tree-SHA512: ca31118f028a19721f2191d86f2dd398144d04df345694575a64aeb293be2f85785201480c3c578a0ec99690516205708558c0fd4168b09313378fd4e60a8412

Backport of Core PR 11041
https://github.com/bitcoin/bitcoin/pull/11041/files
Completes T560
Depends on D1971, D2801

Note to reviewers: LookupBlockIndex was moved from validation.h to chain.h to prevent unnecessary inclusions of validation.h in various files.

Test Plan
make check
test_runner.py

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jasonbcox created this revision.Wed, Apr 10, 17:46
Herald added a reviewer: Restricted Project. · View Herald TranscriptWed, Apr 10, 17:46
jasonbcox added inline comments.Wed, Apr 10, 17:48
src/checkpoints.cpp
10 ↗(On Diff #8025)

Re-adding here since it was removed in D712

src/validation.h
16 ↗(On Diff #8025)

Adding this for BlockMap typedef, which was moved to chain.h in D712

deadalnix requested changes to this revision.Wed, Apr 10, 21:59
deadalnix added inline comments.
src/checkpoints.cpp
10 ↗(On Diff #8025)

Including a giant header that define half the world for just one function is a good sign that function isn't where it should be.

src/validation.h
16 ↗(On Diff #8025)

That was the second sign.

626 ↗(On Diff #8025)

This very clearly belongs into chain.h

This revision now requires changes to proceed.Wed, Apr 10, 21:59
jasonbcox updated this revision to Diff 8031.Wed, Apr 10, 23:31

Move LookupBlockIndex definition to chain.h

jasonbcox edited the summary of this revision. (Show Details)Wed, Apr 10, 23:32
Fabien requested changes to this revision.Fri, Apr 12, 06:16
Fabien added inline comments.
src/rpc/rawtransaction.cpp
183 ↗(On Diff #8031)

This line is not in the original PR, it is removed in PR11838
https://github.com/bitcoin/bitcoin/pull/11838/files

This revision now requires changes to proceed.Fri, Apr 12, 06:16
jasonbcox updated this revision to Diff 8047.Sat, Apr 13, 16:08

Fix dependency + rebase

deadalnix accepted this revision.Sun, Apr 14, 17:11
deadalnix added inline comments.
src/init.cpp
2189 ↗(On Diff #8047)

ut everything in one string and let clang-format do its magic.

jasonbcox updated this revision to Diff 8052.Sun, Apr 14, 17:20

Fix string linting + rebase

Fabien accepted this revision.Mon, Apr 15, 07:48
This revision is now accepted and ready to land.Mon, Apr 15, 07:48
This revision was automatically updated to reflect the committed changes.