Commit 3cfb6624 authored by Sebastian Stammler's avatar Sebastian Stammler

op-node: Add eth.HeaderBlockInfo

And use it in op-batcher.
parent 0dc80987
...@@ -296,5 +296,5 @@ func (l *BatchSubmitter) l1Tip(ctx context.Context) (eth.L1BlockRef, error) { ...@@ -296,5 +296,5 @@ func (l *BatchSubmitter) l1Tip(ctx context.Context) (eth.L1BlockRef, error) {
if err != nil { if err != nil {
return eth.L1BlockRef{}, fmt.Errorf("getting latest L1 block: %w", err) return eth.L1BlockRef{}, fmt.Errorf("getting latest L1 block: %w", err)
} }
return eth.L1BlockRefFromHeader(head), nil return eth.InfoToL1BlockRef(eth.HeaderBlockInfo(head)), nil
} }
...@@ -42,3 +42,44 @@ func ToBlockID(b NumberAndHash) BlockID { ...@@ -42,3 +42,44 @@ func ToBlockID(b NumberAndHash) BlockID {
Number: b.NumberU64(), Number: b.NumberU64(),
} }
} }
// headerBlockInfo is a conversion type of types.Header turning it into a
// BlockInfo.
type headerBlockInfo struct{ *types.Header }
func (h headerBlockInfo) ParentHash() common.Hash {
return h.Header.ParentHash
}
func (h headerBlockInfo) Coinbase() common.Address {
return h.Header.Coinbase
}
func (h headerBlockInfo) Root() common.Hash {
return h.Header.Root
}
func (h headerBlockInfo) NumberU64() uint64 {
return h.Header.Number.Uint64()
}
func (h headerBlockInfo) Time() uint64 {
return h.Header.Time
}
func (h headerBlockInfo) MixDigest() common.Hash {
return h.Header.MixDigest
}
func (h headerBlockInfo) BaseFee() *big.Int {
return h.Header.BaseFee
}
func (h headerBlockInfo) ReceiptHash() common.Hash {
return h.Header.ReceiptHash
}
// HeaderBlockInfo returns h as a BlockInfo implementation.
func HeaderBlockInfo(h *types.Header) BlockInfo {
return headerBlockInfo{h}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment