eth/fiters: add block timestamp

Signed-off-by: tmelhao <tmelhao@gmail.com>
This commit is contained in:
tmelhao 2024-06-03 09:40:52 +00:00
parent 3999f4a32d
commit b4f6cd7f03
2 changed files with 3 additions and 2 deletions

View file

@ -287,7 +287,7 @@ func (f *Filter) checkMatches(ctx context.Context, header *types.Header) ([]*typ
// such as tx index, block hash, etc. // such as tx index, block hash, etc.
// Notably tx hash is NOT filled in because it needs // Notably tx hash is NOT filled in because it needs
// access to block body data. // 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 { if err != nil {
return nil, err return nil, err
} }

View file

@ -96,7 +96,7 @@ type logCacheElem struct {
} }
// cachedLogElem loads block logs from the backend and caches the result. // 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) cached, ok := sys.logsCache.Get(blockHash)
if ok { if ok {
return cached, nil return cached, nil
@ -119,6 +119,7 @@ func (sys *FilterSystem) cachedLogElem(ctx context.Context, blockHash common.Has
log.BlockNumber = number log.BlockNumber = number
log.TxIndex = uint(i) log.TxIndex = uint(i)
log.Index = logIdx log.Index = logIdx
log.BlockTimestamp = time
logIdx++ logIdx++
flattened = append(flattened, log) flattened = append(flattened, log)
} }