mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-23 04:03:49 +00:00
Fix for issue 4205 (optimize eth_getLogs) (#4662)
* optimize eth_getLogs * used the implementation from api._blockReader * used the implementation from api._blockReader
This commit is contained in:
parent
0ca3ff3858
commit
cfc051892e
@ -155,11 +155,11 @@ func (api *APIImpl) GetLogs(ctx context.Context, crit filters.FilterCriteria) ([
|
||||
return nil, err
|
||||
}
|
||||
|
||||
block := uint64(iter.Next())
|
||||
blockNumber := uint64(iter.Next())
|
||||
var logIndex uint
|
||||
var txIndex uint
|
||||
var blockLogs []*types.Log
|
||||
err := tx.ForPrefix(kv.Log, dbutils.EncodeBlockNumber(block), func(k, v []byte) error {
|
||||
err := tx.ForPrefix(kv.Log, dbutils.EncodeBlockNumber(blockNumber), func(k, v []byte) error {
|
||||
var logs types.Logs
|
||||
if err := cbor.Unmarshal(&logs, bytes.NewReader(v)); err != nil {
|
||||
return fmt.Errorf("receipt unmarshal failed: %w", err)
|
||||
@ -187,18 +187,19 @@ func (api *APIImpl) GetLogs(ctx context.Context, crit filters.FilterCriteria) ([
|
||||
continue
|
||||
}
|
||||
|
||||
b, err := api.blockByNumberWithSenders(tx, block)
|
||||
blockHash, err := rawdb.ReadCanonicalHash(tx, blockNumber)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if b == nil {
|
||||
return nil, fmt.Errorf("block not found %d", block)
|
||||
|
||||
body, err := api._blockReader.BodyWithTransactions(ctx, tx, blockHash, blockNumber)
|
||||
if err != nil || body == nil {
|
||||
return nil, fmt.Errorf("block not found %d", blockNumber)
|
||||
}
|
||||
blockHash := b.Hash()
|
||||
for _, log := range blockLogs {
|
||||
log.BlockNumber = block
|
||||
log.BlockNumber = blockNumber
|
||||
log.BlockHash = blockHash
|
||||
log.TxHash = b.Transactions()[log.TxIndex].Hash()
|
||||
log.TxHash = body.Transactions[log.TxIndex].Hash()
|
||||
}
|
||||
logs = append(logs, blockLogs...)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user