@@ -1996,14 +1996,10 @@ func (bc *BlockChain) recoverAncestors(block *types.Block) (common.Hash, error)
1996
1996
}
1997
1997
1998
1998
// collectLogs collects the logs that were generated or removed during
1999
- // the processing of the block that corresponds with the given hash.
2000
- // These logs are later announced as deleted or reborn.
2001
- func (bc * BlockChain ) collectLogs (hash common.Hash , removed bool ) []* types.Log {
2002
- number := bc .hc .GetBlockNumber (hash )
2003
- if number == nil {
2004
- return nil
2005
- }
2006
- receipts := rawdb .ReadReceipts (bc .db , hash , * number , bc .chainConfig )
1999
+ // the processing of a block. These logs are later announced as deleted or reborn.
2000
+ func (bc * BlockChain ) collectLogs (b * types.Block , removed bool ) []* types.Log {
2001
+ receipts := rawdb .ReadRawReceipts (bc .db , b .Hash (), b .NumberU64 ())
2002
+ receipts .DeriveFields (bc .chainConfig , b .Hash (), b .NumberU64 (), b .Transactions ())
2007
2003
2008
2004
var logs []* types.Log
2009
2005
for _ , receipt := range receipts {
@@ -2150,7 +2146,7 @@ func (bc *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
2150
2146
bc .chainSideFeed .Send (ChainSideEvent {Block : oldChain [i ]})
2151
2147
2152
2148
// Collect deleted logs for notification
2153
- if logs := bc .collectLogs (oldChain [i ]. Hash () , true ); len (logs ) > 0 {
2149
+ if logs := bc .collectLogs (oldChain [i ], true ); len (logs ) > 0 {
2154
2150
deletedLogs = append (deletedLogs , logs ... )
2155
2151
}
2156
2152
if len (deletedLogs ) > 512 {
@@ -2165,7 +2161,7 @@ func (bc *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
2165
2161
// New logs:
2166
2162
var rebirthLogs []* types.Log
2167
2163
for i := len (newChain ) - 1 ; i >= 1 ; i -- {
2168
- if logs := bc .collectLogs (newChain [i ]. Hash () , false ); len (logs ) > 0 {
2164
+ if logs := bc .collectLogs (newChain [i ], false ); len (logs ) > 0 {
2169
2165
rebirthLogs = append (rebirthLogs , logs ... )
2170
2166
}
2171
2167
if len (rebirthLogs ) > 512 {
@@ -2220,7 +2216,7 @@ func (bc *BlockChain) SetCanonical(head *types.Block) (common.Hash, error) {
2220
2216
bc .writeHeadBlock (head )
2221
2217
2222
2218
// Emit events
2223
- logs := bc .collectLogs (head . Hash () , false )
2219
+ logs := bc .collectLogs (head , false )
2224
2220
bc .chainFeed .Send (ChainEvent {Block : head , Hash : head .Hash (), Logs : logs })
2225
2221
if len (logs ) > 0 {
2226
2222
bc .logsFeed .Send (logs )
0 commit comments