2

as the source code shows below: transactions in orphaned/uncle block are deleted from local db, but there're some posts say those txs would be put back to tx pool and would be packed later. So which one is correct, did I lost some detail in the code?

// source file: github.com/ethereum/go-ethereum/core/blockchain.go:1246
func (bc *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
    // ...
    // calculate the difference between deleted and added transactions
    diff := types.TxDifference(deletedTxs, addedTxs)
    // When transactions get deleted from the database that means the
    // receipts that were created in the fork must also be deleted
    for _, tx := range diff {
        rawdb.DeleteTxLookupEntry(bc.db, tx.Hash())
    }
    // ...
}
1

The code you are posting is executed during a chain split. A chain split is when you have one chain on local node, and suddenly a longer chain comes from another node. So, your node must delete all blocks that are invalid, and this is what reorg() does.

There is nothing in reorg() function indicating that deleted TXs are put back in the txpool. However, txpool is listening to chainHead event, and after chainsplit it is going to get events of newly created blocks, so the pool will be updated.

  • yeah, i found the code, that's whtat txpool.reset() does, thanks – Jason Sep 6 '18 at 6:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.