core, eth: polish code comment

This commit is contained in:
Gary Rong 2025-05-02 21:31:05 +08:00
parent a3663464aa
commit a92dadcf25
3 changed files with 6 additions and 11 deletions

View file

@ -271,8 +271,7 @@ func (bc *BlockChain) GetAncestor(hash common.Hash, number, ancestor uint64, max
// GetTransactionLookup retrieves the lookup along with the transaction // GetTransactionLookup retrieves the lookup along with the transaction
// itself associate with the given transaction hash. // itself associate with the given transaction hash.
// //
// A null will be returned in the transaction is not found. The transaction is not existent // A null will be returned if the transaction is not found. This can be due to
// // from the node's perspective. This can be due to
// the transaction indexer not being finished. The caller must explicitly check // the transaction indexer not being finished. The caller must explicitly check
// the indexer progress. // the indexer progress.
func (bc *BlockChain) GetTransactionLookup(hash common.Hash) (*rawdb.LegacyTxLookupEntry, *types.Transaction) { 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. // this is clearly an unintended and unexpected situation.
return true return true
} }
if !progress.Done() { return progress.Done()
return false
}
return true
} }
// HasState checks if state trie is fully present in the database or not. // HasState checks if state trie is fully present in the database or not.

View file

@ -220,7 +220,7 @@ func (indexer *txIndexer) loop(chain *BlockChain) {
stop chan struct{} // Non-nil if background routine is active stop chan struct{} // Non-nil if background routine is active
done 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 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) headCh = make(chan ChainHeadEvent)
sub = chain.SubscribeChainHeadEvent(headCh) sub = chain.SubscribeChainHeadEvent(headCh)

View file

@ -349,10 +349,9 @@ func (b *EthAPIBackend) GetPoolTransaction(hash common.Hash) *types.Transaction
// GetTransaction retrieves the lookup along with the transaction itself associate // GetTransaction retrieves the lookup along with the transaction itself associate
// with the given transaction hash. // with the given transaction hash.
// //
// A null will be returned in the transaction is not found. The transaction is not existent // A null will be returned if the transaction is not found. The transaction is not
// // from the node's perspective. This can be due to // existent from the node's perspective. This can be due to the transaction indexer
// the transaction indexer not being finished. The caller must explicitly check // not being finished. The caller must explicitly check the indexer progress.
// the indexer progress.
func (b *EthAPIBackend) GetTransaction(txHash common.Hash) (bool, *types.Transaction, common.Hash, uint64, uint64) { func (b *EthAPIBackend) GetTransaction(txHash common.Hash) (bool, *types.Transaction, common.Hash, uint64, uint64) {
lookup, tx := b.eth.blockchain.GetTransactionLookup(txHash) lookup, tx := b.eth.blockchain.GetTransactionLookup(txHash)
if lookup == nil || tx == nil { if lookup == nil || tx == nil {