Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1709: ChainDB: add blocks asynchronously r=edsko a=mrBliss Fixes #1463. Instead of adding blocks synchronously, they are now put into a queue, after which `addBlockAsync` returns an `AddBlockResult`, which can be used to wait until the block has been processed. A background thread will read the blocks from the queue and add them synchronously to the ChainDB. The queue is limited in size; when it is full, callers of `addBlockAsync` might still have to wait. With this asynchronous approach, threads adding blocks asynchronously can be killed without worries, the background thread processing the blocks synchronously won't be killed. Only when the whole ChainDB shuts down will that background thread get killed. But since there will be no more in-memory state, it can't get out of sync with the file system state. On the next startup, a correct in-memory state will be reconstructed from the file system state. By letting the BlockFetchClient add blocks asynchronously, we also get a 20-40% bulk chain sync speed-up in some microbenchmarks. Co-authored-by: Thomas Winant <[email protected]>
- Loading branch information