Commit b7e02f6f authored by pcw109550's avatar pcw109550

op-node: JSON Marshaling for span batch

parent 874fb900
...@@ -3,6 +3,7 @@ package derive ...@@ -3,6 +3,7 @@ package derive
import ( import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
"encoding/json"
"errors" "errors"
"fmt" "fmt"
"io" "io"
...@@ -452,6 +453,22 @@ type SpanBatch struct { ...@@ -452,6 +453,22 @@ type SpanBatch struct {
Batches []*SpanBatchElement // List of block input in derived form Batches []*SpanBatchElement // List of block input in derived form
} }
// spanBatchMarshaling is a helper type used for JSON marshaling.
type spanBatchMarshaling struct {
ParentCheck []hexutil.Bytes `json:"parent_check"`
L1OriginCheck []hexutil.Bytes `json:"l1_origin_check"`
Batches []*SpanBatchElement `json:"span_batch_elements"`
}
func (b *SpanBatch) MarshalJSON() ([]byte, error) {
spanBatch := spanBatchMarshaling{
ParentCheck: []hexutil.Bytes{b.ParentCheck[:]},
L1OriginCheck: []hexutil.Bytes{b.L1OriginCheck[:]},
Batches: b.Batches,
}
return json.Marshal(spanBatch)
}
// GetBatchType returns its batch type (batch_version) // GetBatchType returns its batch type (batch_version)
func (b *SpanBatch) GetBatchType() int { func (b *SpanBatch) GetBatchType() int {
return SpanBatchType return SpanBatchType
......
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