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
Reviewers: deadalnix, Fabien, #bitcoin_abc
Reviewed By: deadalnix, Fabien, #bitcoin_abc
Differential Revision: https://reviews.bitcoinabc.org/D2793