Commit 9bea5ab3 authored by Sebastian Stammler's avatar Sebastian Stammler

op-node: Add L1BlockRefFromHeader

parent 6c6d142d
...@@ -4,6 +4,7 @@ import ( ...@@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
) )
type BlockID struct { type BlockID struct {
...@@ -47,6 +48,15 @@ type L1BlockRef struct { ...@@ -47,6 +48,15 @@ type L1BlockRef struct {
Time uint64 `json:"timestamp"` Time uint64 `json:"timestamp"`
} }
func L1BlockRefFromHeader(block *types.Header) L1BlockRef {
return L1BlockRef{
Hash: block.Hash(),
Number: block.Number.Uint64(),
ParentHash: block.ParentHash,
Time: block.Time,
}
}
func (id L1BlockRef) String() string { func (id L1BlockRef) String() string {
return fmt.Sprintf("%s:%d", id.Hash.String(), id.Number) return fmt.Sprintf("%s:%d", id.Hash.String(), id.Number)
} }
......
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