From a92dadcf25755df8bde40c4c08c60ce77f5886c6 Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Fri, 2 May 2025 21:31:05 +0800 Subject: [PATCH] core, eth: polish code comment --- core/blockchain_reader.go | 8 ++------ core/txindexer.go | 2 +- eth/api_backend.go | 7 +++---- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/core/blockchain_reader.go b/core/blockchain_reader.go index f68ff43ada..7bfdd692fe 100644 --- a/core/blockchain_reader.go +++ b/core/blockchain_reader.go @@ -271,8 +271,7 @@ func (bc *BlockChain) GetAncestor(hash common.Hash, number, ancestor uint64, max // GetTransactionLookup retrieves the lookup along with the transaction // itself associate with the given transaction hash. // -// A null will be returned in the transaction is not found. The transaction is not existent -// // from the node's perspective. This can be due to +// A null will be returned if the transaction is not found. This can be due to // the transaction indexer not being finished. The caller must explicitly check // the indexer progress. func (bc *BlockChain) GetTransactionLookup(hash common.Hash) (*rawdb.LegacyTxLookupEntry, *types.Transaction) { @@ -312,10 +311,7 @@ func (bc *BlockChain) TxIndexDone(ctx context.Context) bool { // this is clearly an unintended and unexpected situation. return true } - if !progress.Done() { - return false - } - return true + return progress.Done() } // HasState checks if state trie is fully present in the database or not. diff --git a/core/txindexer.go b/core/txindexer.go index 9469ed04de..135b56e777 100644 --- a/core/txindexer.go +++ b/core/txindexer.go @@ -220,7 +220,7 @@ func (indexer *txIndexer) loop(chain *BlockChain) { stop chan struct{} // Non-nil if background routine is active done chan struct{} // Non-nil if background routine is active head = indexer.resolveHead() // The latest announced chain head - lastTail = rawdb.ReadTxIndexTail(indexer.db) // // The oldest indexed block, nil means nothing indexed + lastTail = rawdb.ReadTxIndexTail(indexer.db) // The oldest indexed block, nil means nothing indexed headCh = make(chan ChainHeadEvent) sub = chain.SubscribeChainHeadEvent(headCh) diff --git a/eth/api_backend.go b/eth/api_backend.go index 0372fb6664..681016e424 100644 --- a/eth/api_backend.go +++ b/eth/api_backend.go @@ -349,10 +349,9 @@ func (b *EthAPIBackend) GetPoolTransaction(hash common.Hash) *types.Transaction // GetTransaction retrieves the lookup along with the transaction itself associate // with the given transaction hash. // -// A null will be returned in the transaction is not found. The transaction is not existent -// // from the node's perspective. This can be due to -// the transaction indexer not being finished. The caller must explicitly check -// the indexer progress. +// A null will be returned if the transaction is not found. The transaction is not +// existent from the node's perspective. This can be due to the transaction indexer +// not being finished. The caller must explicitly check the indexer progress. func (b *EthAPIBackend) GetTransaction(txHash common.Hash) (bool, *types.Transaction, common.Hash, uint64, uint64) { lookup, tx := b.eth.blockchain.GetTransactionLookup(txHash) if lookup == nil || tx == nil {