The base index class is responsible for detecting reorgs and calling the appropriate methods from the child class: CustomRemove()
up to the forking point, then CustomAppend()
to connect the new chain blocks. This happens during both initial sync and the validation event. I’m pretty confident we can safely remove the extra check.
Furthermore, since the index child class receives block connection and disconnection events in order, I don’t see why it should care about reorgs at all (speaking generally here, for all index child classes). That’s one of the base class responsibilities.
Also, if we do want to keep the previous block check for some reason, I think we could cache it during CustomInit()
, then update it in both CustomAppend()
and CustomRemove()
. Or.. we could keep the base class’s m_best_block_index
updated with every processed block too. Either way, I think we can avoid accessing disk for this.