Skip to content

Commit 75f51f2

Browse files
committed
Prepare block connection logic for headers-first.
This changes the block processing logic from "try to atomically switch to a new block" to a continuous "(dis)connect a block, aiming for the assumed best chain". This means the smallest atomic operations on the chainstate become individual block connections or disconnections, instead of entire reorganizations. It may mean that we try to reorganize to one block, fail, and rereorganize again to the old block. This is slower, but doesn't require unbounded RAM. It also means that a ConnectBlock which fails may be no longer called from the ProcessBlock which knows which node sent it. To deal with that, a mapBlockSource is kept, and invalid blocks cause asynchronous "reject" messages and banning (if necessary).
1 parent 0ec16f3 commit 75f51f2

File tree

3 files changed

+256
-204
lines changed

3 files changed

+256
-204
lines changed

src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ bool AppInit2(boost::thread_group& threadGroup)
983983

984984
// scan for better chains in the block chain database, that are not yet connected in the active best chain
985985
CValidationState state;
986-
if (!ConnectBestBlock(state))
986+
if (!ActivateBestChain(state))
987987
strErrors << "Failed to connect best block";
988988

989989
std::vector<boost::filesystem::path> vImportFiles;

0 commit comments

Comments
 (0)