Node/EVM: Add timestamp to block (#3490)
This commit is contained in:
parent
9be9a564b6
commit
36022b8873
|
@ -219,6 +219,7 @@ func (b *BatchPollConnector) getBlocks(ctx context.Context, logger *zap.Logger)
|
|||
|
||||
ret[idx] = &NewBlock{
|
||||
Number: &n,
|
||||
Time: uint64(m.Time),
|
||||
Hash: m.Hash,
|
||||
L1BlockNumber: l1bn,
|
||||
Finality: finality,
|
||||
|
@ -276,6 +277,7 @@ func (b *BatchPollConnector) getBlockRange(ctx context.Context, logger *zap.Logg
|
|||
|
||||
ret[idx] = &NewBlock{
|
||||
Number: &n,
|
||||
Time: uint64(m.Time),
|
||||
Hash: m.Hash,
|
||||
L1BlockNumber: l1bn,
|
||||
Finality: finality,
|
||||
|
|
|
@ -30,6 +30,7 @@ type BlockMarshaller struct {
|
|||
type NewBlock struct {
|
||||
Number *big.Int
|
||||
Hash common.Hash
|
||||
Time uint64
|
||||
L1BlockNumber *big.Int // This is only populated on some chains (Arbitrum)
|
||||
Finality FinalityLevel
|
||||
}
|
||||
|
@ -38,6 +39,7 @@ func (b *NewBlock) Copy(f FinalityLevel) *NewBlock {
|
|||
return &NewBlock{
|
||||
Number: b.Number,
|
||||
Hash: b.Hash,
|
||||
Time: b.Time,
|
||||
L1BlockNumber: b.L1BlockNumber,
|
||||
Finality: f,
|
||||
}
|
||||
|
|
|
@ -47,21 +47,15 @@ func (c *InstantFinalityConnector) SubscribeForBlocks(ctx context.Context, errC
|
|||
c.logger.Error("new header block number is nil")
|
||||
continue
|
||||
}
|
||||
sink <- &NewBlock{
|
||||
block := &NewBlock{
|
||||
Number: ev.Number,
|
||||
Time: ev.Time,
|
||||
Hash: ev.Hash(),
|
||||
Finality: Finalized,
|
||||
}
|
||||
sink <- &NewBlock{
|
||||
Number: ev.Number,
|
||||
Hash: ev.Hash(),
|
||||
Finality: Safe,
|
||||
}
|
||||
sink <- &NewBlock{
|
||||
Number: ev.Number,
|
||||
Hash: ev.Hash(),
|
||||
Finality: Latest,
|
||||
}
|
||||
sink <- block
|
||||
sink <- block.Copy(Safe)
|
||||
sink <- block.Copy(Latest)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -232,6 +232,7 @@ func getBlock(ctx context.Context, logger *zap.Logger, conn Connector, str strin
|
|||
|
||||
return &NewBlock{
|
||||
Number: &n,
|
||||
Time: uint64(m.Time),
|
||||
Hash: m.Hash,
|
||||
L1BlockNumber: l1bn,
|
||||
Finality: blockFinality,
|
||||
|
|
|
@ -147,6 +147,7 @@ func (c *PolygonConnector) SubscribeForBlocks(ctx context.Context, errC chan err
|
|||
}
|
||||
sink <- &NewBlock{
|
||||
Number: ev.Number,
|
||||
Time: ev.Time,
|
||||
Hash: ev.Hash(),
|
||||
Finality: Latest,
|
||||
}
|
||||
|
|
|
@ -604,6 +604,7 @@ func (w *Watcher) Run(parentCtx context.Context) error {
|
|||
currentHash := ev.Hash
|
||||
logger.Debug("processing new header",
|
||||
zap.Stringer("current_block", ev.Number),
|
||||
zap.Uint64("block_time", ev.Time),
|
||||
zap.Stringer("current_blockhash", currentHash),
|
||||
zap.Stringer("finality", ev.Finality),
|
||||
zap.String("eth_network", w.networkName))
|
||||
|
|
Loading…
Reference in New Issue