Patch for concurrent iterator & others (onto v1.11.6) #386
@ -1996,14 +1996,10 @@ func (bc *BlockChain) recoverAncestors(block *types.Block) (common.Hash, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// collectLogs collects the logs that were generated or removed during
|
// collectLogs collects the logs that were generated or removed during
|
||||||
// the processing of the block that corresponds with the given hash.
|
// the processing of a block. These logs are later announced as deleted or reborn.
|
||||||
// These logs are later announced as deleted or reborn.
|
func (bc *BlockChain) collectLogs(b *types.Block, removed bool) []*types.Log {
|
||||||
func (bc *BlockChain) collectLogs(hash common.Hash, removed bool) []*types.Log {
|
receipts := rawdb.ReadRawReceipts(bc.db, b.Hash(), b.NumberU64())
|
||||||
number := bc.hc.GetBlockNumber(hash)
|
receipts.DeriveFields(bc.chainConfig, b.Hash(), b.NumberU64(), b.Transactions())
|
||||||
if number == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
receipts := rawdb.ReadReceipts(bc.db, hash, *number, bc.chainConfig)
|
|
||||||
|
|
||||||
var logs []*types.Log
|
var logs []*types.Log
|
||||||
for _, receipt := range receipts {
|
for _, receipt := range receipts {
|
||||||
@ -2150,7 +2146,7 @@ func (bc *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
|
|||||||
bc.chainSideFeed.Send(ChainSideEvent{Block: oldChain[i]})
|
bc.chainSideFeed.Send(ChainSideEvent{Block: oldChain[i]})
|
||||||
|
|
||||||
// Collect deleted logs for notification
|
// Collect deleted logs for notification
|
||||||
if logs := bc.collectLogs(oldChain[i].Hash(), true); len(logs) > 0 {
|
if logs := bc.collectLogs(oldChain[i], true); len(logs) > 0 {
|
||||||
deletedLogs = append(deletedLogs, logs...)
|
deletedLogs = append(deletedLogs, logs...)
|
||||||
}
|
}
|
||||||
if len(deletedLogs) > 512 {
|
if len(deletedLogs) > 512 {
|
||||||
@ -2165,7 +2161,7 @@ func (bc *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
|
|||||||
// New logs:
|
// New logs:
|
||||||
var rebirthLogs []*types.Log
|
var rebirthLogs []*types.Log
|
||||||
for i := len(newChain) - 1; i >= 1; i-- {
|
for i := len(newChain) - 1; i >= 1; i-- {
|
||||||
if logs := bc.collectLogs(newChain[i].Hash(), false); len(logs) > 0 {
|
if logs := bc.collectLogs(newChain[i], false); len(logs) > 0 {
|
||||||
rebirthLogs = append(rebirthLogs, logs...)
|
rebirthLogs = append(rebirthLogs, logs...)
|
||||||
}
|
}
|
||||||
if len(rebirthLogs) > 512 {
|
if len(rebirthLogs) > 512 {
|
||||||
@ -2220,7 +2216,7 @@ func (bc *BlockChain) SetCanonical(head *types.Block) (common.Hash, error) {
|
|||||||
bc.writeHeadBlock(head)
|
bc.writeHeadBlock(head)
|
||||||
|
|
||||||
// Emit events
|
// Emit events
|
||||||
logs := bc.collectLogs(head.Hash(), false)
|
logs := bc.collectLogs(head, false)
|
||||||
bc.chainFeed.Send(ChainEvent{Block: head, Hash: head.Hash(), Logs: logs})
|
bc.chainFeed.Send(ChainEvent{Block: head, Hash: head.Hash(), Logs: logs})
|
||||||
if len(logs) > 0 {
|
if len(logs) > 0 {
|
||||||
bc.logsFeed.Send(logs)
|
bc.logsFeed.Send(logs)
|
||||||
|
Loading…
Reference in New Issue
Block a user