new: add filter for block logs

This commit is contained in:
Jaynti Kanani 2020-10-18 16:26:55 +05:30
parent 432749d6a1
commit 4dae6739f9
No known key found for this signature in database
GPG key ID: 4396982C976BAE5E

View file

@ -0,0 +1,30 @@
package filters
import (
"context"
"github.com/maticnetwork/bor/common"
"github.com/maticnetwork/bor/core/rawdb"
"github.com/maticnetwork/bor/core/types"
)
func (b *testBackend) GetBorBlockReceipt(ctx context.Context, hash common.Hash) (*types.BorReceipt, error) {
number := rawdb.ReadHeaderNumber(b.db, hash)
if number == nil {
return nil, nil
}
receipt := rawdb.ReadBorReceipt(b.db, hash, *number)
if receipt == nil {
return nil, nil
}
return receipt, nil
}
func (b *testBackend) GetBorBlockLogs(ctx context.Context, hash common.Hash) ([]*types.Log, error) {
receipt, err := b.GetBorBlockReceipt(ctx, hash)
if receipt == nil || err != nil {
return nil, nil
}
return receipt.Logs, nil
}