MCPcopy Create free account
hub / github.com/ElementsProject/elements / Rewind

Method Rewind

src/index/base.cpp:223–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221}
222
223bool BaseIndex::Rewind(const CBlockIndex* current_tip, const CBlockIndex* new_tip)
224{
225 assert(current_tip == m_best_block_index);
226 assert(current_tip->GetAncestor(new_tip->nHeight) == new_tip);
227
228 // In the case of a reorg, ensure persisted block locator is not stale.
229 // Pruning has a minimum of 288 blocks-to-keep and getting the index
230 // out of sync may be possible but a users fault.
231 // In case we reorg beyond the pruned depth, ReadBlockFromDisk would
232 // throw and lead to a graceful shutdown
233 m_best_block_index = new_tip;
234 if (!Commit()) {
235 // If commit fails, revert the best block index to avoid corruption.
236 m_best_block_index = current_tip;
237 return false;
238 }
239
240 return true;
241}
242
243void BaseIndex::BlockConnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* pindex)
244{

Callers 3

DeserializeBlockTestFunction · 0.45
PrevectorDeserializeFunction · 0.45

Calls 1

GetAncestorMethod · 0.80

Tested by

no test coverage detected