From b4f6cd7f03011ce830d2d90eb2be65bc51def2f2 Mon Sep 17 00:00:00 2001 From: tmelhao Date: Mon, 3 Jun 2024 09:40:52 +0000 Subject: [PATCH] eth/fiters: add block timestamp Signed-off-by: tmelhao --- eth/filters/filter.go | 2 +- eth/filters/filter_system.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/eth/filters/filter.go b/eth/filters/filter.go index 09ccb93907..4a0f68092d 100644 --- a/eth/filters/filter.go +++ b/eth/filters/filter.go @@ -287,7 +287,7 @@ func (f *Filter) checkMatches(ctx context.Context, header *types.Header) ([]*typ // such as tx index, block hash, etc. // Notably tx hash is NOT filled in because it needs // access to block body data. - cached, err := f.sys.cachedLogElem(ctx, hash, header.Number.Uint64()) + cached, err := f.sys.cachedLogElem(ctx, hash, header.Number.Uint64(), header.Time) if err != nil { return nil, err } diff --git a/eth/filters/filter_system.go b/eth/filters/filter_system.go index a3a2787a41..e69904c66d 100644 --- a/eth/filters/filter_system.go +++ b/eth/filters/filter_system.go @@ -96,7 +96,7 @@ type logCacheElem struct { } // cachedLogElem loads block logs from the backend and caches the result. -func (sys *FilterSystem) cachedLogElem(ctx context.Context, blockHash common.Hash, number uint64) (*logCacheElem, error) { +func (sys *FilterSystem) cachedLogElem(ctx context.Context, blockHash common.Hash, number, time uint64) (*logCacheElem, error) { cached, ok := sys.logsCache.Get(blockHash) if ok { return cached, nil @@ -119,6 +119,7 @@ func (sys *FilterSystem) cachedLogElem(ctx context.Context, blockHash common.Has log.BlockNumber = number log.TxIndex = uint(i) log.Index = logIdx + log.BlockTimestamp = time logIdx++ flattened = append(flattened, log) }