Commit b7e02f6f authored by pcw109550's avatar pcw109550

op-node: JSON Marshaling for span batch

parent 874fb900
......@@ -3,6 +3,7 @@ package derive
import (
"bytes"
"encoding/binary"
"encoding/json"
"errors"
"fmt"
"io"
......@@ -452,6 +453,22 @@ type SpanBatch struct {
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)
func (b *SpanBatch) GetBatchType() int {
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