This question is centered around the implementation of how transactions on an orphanfrom a reorganized block return to the mem poolmempool.
In my understanding, once a block becomes orphanorganized out of the best chain all it'sits transactions (that aren't on other non-orphanin blocks of the best chain) need to return to the mem poolmempool.
Do we start from genesis block until we reach the last block of the active chain checking every transaction along the way, or is it there a more efficient algorithm that's based on some constraint/property that allows the algorithm to start from a more recent block?
Proto code for starting from the genesis block:
Blockchain blockchain = ...
function Dictionary<Key, Tx> deleteOrphanTx (Dictionary<Key, Tx> orphanTx) {
foreach (Block currBlock : blockchain.getBlocks())
foreach (Tx tx : currBlock.getTx())
Key txKey = tx.getKey();
if(orphanTx.contains(txKey)
orphanTx.remove(txKey);
return orphanTx;
}