Skip to content

Commit

Permalink
Prepare block connection logic for headers-first.
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
sipa committed Jan 27, 2014
1 parent 0ec16f3 commit 75f51f2
Show file tree
Hide file tree
Showing 3 changed files with 256 additions and 204 deletions.
2 changes: 1 addition & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ bool AppInit2(boost::thread_group& threadGroup)

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

std::vector<boost::filesystem::path> vImportFiles;
Expand Down
Loading

0 comments on commit 75f51f2

Please sign in to comment.