From 5061dd984108fc68a50c687bbe76167901f63536 Mon Sep 17 00:00:00 2001 From: Liam Lai Date: Tue, 21 Dec 2021 08:47:23 +0300 Subject: [PATCH] add few comments in code --- consensus/XDPoS/engines/engine_v1/engine.go | 1 + core/blockchain.go | 3 +++ 2 files changed, 4 insertions(+) diff --git a/consensus/XDPoS/engines/engine_v1/engine.go b/consensus/XDPoS/engines/engine_v1/engine.go index d606c1aea3..2a955e0429 100644 --- a/consensus/XDPoS/engines/engine_v1/engine.go +++ b/consensus/XDPoS/engines/engine_v1/engine.go @@ -483,6 +483,7 @@ func (x *XDPoS_v1) snapshot(chain consensus.ChainReader, number uint64, hash com } parents = parents[:len(parents)-1] } else if selfHeader != nil && selfHeader.Hash() == hash { + // it prevents db doesn't have current block info, can be removed by refactor blockchain.go reorg function call. header = selfHeader } else { // No explicit parents (or no more left), reach out to the database diff --git a/core/blockchain.go b/core/blockchain.go index cf88a582a6..ff760d0c8b 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1345,6 +1345,9 @@ func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types. reorg = block.NumberU64() > currentBlock.NumberU64() } + // This is the ETH fix. We shall ultimately have this workflow, + // but due to below code has diverged significantly between ETH and XDC, and current issue we have, + // it's best to have it in a different PR with more investigations. // if reorg { // // Write the positional metadata for transaction and receipt lookups // if err := WriteTxLookupEntries(batch, block); err != nil {