For discussion of https://github.com/bitcoin/bitcoin/pull/24008/commits/c14ae132c5a5204a9a755c84c6de05fb30459221
- IF1:
if(!m_snapshot_chainstate)=> useibd - IF2:
if(m_blockman.LookupBlockIndex(blockhash) == nullptr)=> usesnapshot- This means we use the snapshot chainstate if we have not seen this block’s header yet, implied from it not being in
m_block_index
- This means we use the snapshot chainstate if we have not seen this block’s header yet, implied from it not being in
- IF3:
if (!m_snapshot_chainstate->m_chain.Contains(pblock)))=> usesnapshot- This means we use the snapshot chainstate if the block header is not part of the current best chain (included in
m_chain) which can mean we have not validated the full block yet or the block is not part of the best chain after validation
- This means we use the snapshot chainstate if the block header is not part of the current best chain (included in
- FB: fallback => use
ibd
| New Block location | A) Before Snapshot | B) After Snapshot | C) At Tip |
|---|---|---|---|
| 1. Normal operation | Block location doesn't matter, the guard clause is hit because there is no snapshot so the block goes to ibd. (IF1) |
<-- | <-- |
| 2. Snapshot loading | We have seen the the header but not the block, going to snapshot (inactive). If we have received the block already, it's going to ibd. (IF3) |
We have seen the the header but not the block, going to snapshot (inactive). If we have received the block already, it's going to ibd. (IF3) |
We have not seen the header yet so snapshot is used even though it's considered "inactive" at this moment. (IF2) |
| 3. Snapshot loaded | We have seen the the header but not the block, going to snapshot. If we have received the block already, it's going to ibd. (IF3) |
We have seen the the header but not the block, going to snapshot. If we have received the block already, it's going to ibd. (IF3) |
We have not seen the header yet so snapshot is used. (IF2) |
| 4. Snapshot has hit tip | We have seen the the header but not the block, going to snapshot. If we have received the block already, it's going to ibd. (IF3) |
We have seen the the header and the block, going to ibd. (FB) |
We have not seen the header yet so snapshot is used. (IF2) |
| 5. Validation complete, pending restart | ibd would be used but it is now m_disabled so there is no effect. (FB) |
ibd would be used but it is now m_disabled so there is no effect. (FB) |
We have not seen the header yet so snapshot is used. snapshot now has the complete chain and is pending to become ibd after restart. (IF2) |
| 6. Validation complete, after restart | Like in normal operation, only ibd (used to be snapshot) is available in any case. (IF1) |
<-- | <-- |