Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

Commit

Permalink
bet
Browse files Browse the repository at this point in the history
  • Loading branch information
itsdevbear committed Jan 20, 2024
1 parent 7a15507 commit 055dab4
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions eth/core/chain_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ func (bc *blockchain) CurrentHeader() *ethtypes.Header {
if block == nil || !ok {
return nil
}
bc.blockNumCache.Add(block.Number().Uint64(), block)
bc.blockHashCache.Add(block.Hash(), block)
// bc.blockNumCache.Add(block.Number().Uint64(), block)
// bc.blockHashCache.Add(block.Hash(), block)
return block.Header()
}

Expand All @@ -74,8 +74,8 @@ func (bc *blockchain) CurrentBlock() *ethtypes.Header {
if block == nil || !ok {
return nil
}
bc.blockNumCache.Add(block.Number().Uint64(), block)
bc.blockHashCache.Add(block.Hash(), block)
// bc.blockNumCache.Add(block.Number().Uint64(), block)
// bc.blockHashCache.Add(block.Hash(), block)
return block.Header()
}

Expand All @@ -91,8 +91,8 @@ func (bc *blockchain) CurrentFinalBlock() *ethtypes.Header {
if fb == nil || !ok {
return nil
}
bc.blockNumCache.Add(fb.Number().Uint64(), fb)
bc.blockHashCache.Add(fb.Hash(), fb)
// bc.blockNumCache.Add(fb.Number().Uint64(), fb)
// bc.blockHashCache.Add(fb.Hash(), fb)
return fb.Header()
}

Expand Down Expand Up @@ -133,16 +133,16 @@ func (bc *blockchain) GetBlockByHash(hash common.Hash) *ethtypes.Block {
}

// Cache the found block for next time and return
bc.blockNumCache.Add(block.Number().Uint64(), block)
bc.blockHashCache.Add(hash, block)
// bc.blockNumCache.Add(block.Number().Uint64(), block)
// bc.blockHashCache.Add(hash, block)
return block
}

// GetBlock retrieves a block from the database by hash and number, caching it if found.
func (bc *blockchain) GetBlockByNumber(number uint64) *ethtypes.Block {
// check the block number cache
if block, ok := bc.blockNumCache.Get(number); ok {
bc.blockHashCache.Add(block.Hash(), block)
// bc.blockHashCache.Add(block.Hash(), block)
return block
}

Expand Down Expand Up @@ -170,8 +170,8 @@ func (bc *blockchain) GetBlockByNumber(number uint64) *ethtypes.Block {
}

// Cache the found block for next time and return
bc.blockNumCache.Add(number, block)
bc.blockHashCache.Add(block.Hash(), block)
// bc.blockNumCache.Add(number, block)
// bc.blockHashCache.Add(block.Hash(), block)
return block
}

Expand Down Expand Up @@ -203,7 +203,7 @@ func (bc *blockchain) GetReceiptsByHash(blockHash common.Hash) ethtypes.Receipts
}

// cache the found receipts for next time and return
bc.receiptsCache.Add(blockHash, receipts)
// bc.receiptsCache.Add(blockHash, receipts)
derived, err := bc.deriveReceipts(receipts, blockHash)
if err != nil {
bc.logger.Error("failed to derive receipts", "err", err)
Expand Down Expand Up @@ -239,7 +239,7 @@ func (bc *blockchain) GetTransactionLookup(
}

// cache the found transaction for next time and return
bc.txLookupCache.Add(hash, txLookupEntry)
// bc.txLookupCache.Add(hash, txLookupEntry)
return txLookupEntry
}

Expand Down

0 comments on commit 055dab4

Please sign in to comment.