Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
9f9cf618
Unverified
Commit
9f9cf618
authored
Oct 30, 2023
by
protolambda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-node: reduce batch inner type encode/decode methods to just one way
Signed-off-by:
protolambda
<
proto@protolambda.com
>
parent
72cd6482
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4 additions
and
32 deletions
+4
-32
batch.go
op-node/rollup/derive/batch.go
+1
-3
singular_batch.go
op-node/rollup/derive/singular_batch.go
+0
-10
span_batch.go
op-node/rollup/derive/span_batch.go
+0
-17
span_batch_test.go
op-node/rollup/derive/span_batch_test.go
+3
-2
No files found.
op-node/rollup/derive/batch.go
View file @
9f9cf618
...
...
@@ -53,8 +53,6 @@ type InnerBatchData interface {
GetBatchType
()
int
encode
(
w
io
.
Writer
)
error
decode
(
r
*
bytes
.
Reader
)
error
encodeBytes
()
([]
byte
,
error
)
decodeBytes
(
data
[]
byte
)
error
}
// EncodeRLP implements rlp.Encoder
...
...
@@ -121,7 +119,7 @@ func (b *BatchData) decodeTyped(data []byte) error {
default
:
return
fmt
.
Errorf
(
"unrecognized batch type: %d"
,
data
[
0
])
}
if
err
:=
inner
.
decode
Bytes
(
data
[
1
:
]
);
err
!=
nil
{
if
err
:=
inner
.
decode
(
bytes
.
NewReader
(
data
[
1
:
])
);
err
!=
nil
{
return
err
}
b
.
inner
=
inner
...
...
op-node/rollup/derive/singular_batch.go
View file @
9f9cf618
...
...
@@ -65,13 +65,3 @@ func (b *SingularBatch) encode(w io.Writer) error {
func
(
b
*
SingularBatch
)
decode
(
r
*
bytes
.
Reader
)
error
{
return
rlp
.
Decode
(
r
,
b
)
}
// encodeBytes returns the byte encoding of SingularBatch
func
(
b
*
SingularBatch
)
encodeBytes
()
([]
byte
,
error
)
{
return
rlp
.
EncodeToBytes
(
b
)
}
// decodeBytes parses data into b from data
func
(
b
*
SingularBatch
)
decodeBytes
(
data
[]
byte
)
error
{
return
rlp
.
DecodeBytes
(
data
,
b
)
}
op-node/rollup/derive/span_batch.go
View file @
9f9cf618
...
...
@@ -224,12 +224,6 @@ func (bp *spanBatchPayload) decodePayload(r *bytes.Reader) error {
return
nil
}
// decodeBytes parses data into b from data
func
(
b
*
RawSpanBatch
)
decodeBytes
(
data
[]
byte
)
error
{
r
:=
bytes
.
NewReader
(
data
)
return
b
.
decode
(
r
)
}
// decode reads the byte encoding of SpanBatch from Reader stream
func
(
b
*
RawSpanBatch
)
decode
(
r
*
bytes
.
Reader
)
error
{
if
r
.
Len
()
>
MaxSpanBatchSize
{
...
...
@@ -383,17 +377,6 @@ func (b *RawSpanBatch) encode(w io.Writer) error {
return
nil
}
// encodeBytes returns the byte encoding of SpanBatch
func
(
b
*
RawSpanBatch
)
encodeBytes
()
([]
byte
,
error
)
{
buf
:=
encodeBufferPool
.
Get
()
.
(
*
bytes
.
Buffer
)
defer
encodeBufferPool
.
Put
(
buf
)
buf
.
Reset
()
if
err
:=
b
.
encode
(
buf
);
err
!=
nil
{
return
[]
byte
{},
err
}
return
buf
.
Bytes
(),
nil
}
// derive converts RawSpanBatch into SpanBatch, which has a list of spanBatchElement.
// We need chain config constants to derive values for making payload attributes.
func
(
b
*
RawSpanBatch
)
derive
(
blockTime
,
genesisTimestamp
uint64
,
chainID
*
big
.
Int
)
(
*
SpanBatch
,
error
)
{
...
...
op-node/rollup/derive/span_batch_test.go
View file @
9f9cf618
...
...
@@ -294,11 +294,12 @@ func TestSpanBatchRoundTrip(t *testing.T) {
rawSpanBatch
:=
RandomRawSpanBatch
(
rng
,
chainID
)
result
,
err
:=
rawSpanBatch
.
encodeBytes
()
var
result
bytes
.
Buffer
err
:=
rawSpanBatch
.
encode
(
&
result
)
require
.
NoError
(
t
,
err
)
var
sb
RawSpanBatch
err
=
sb
.
decode
Bytes
(
result
)
err
=
sb
.
decode
(
bytes
.
NewReader
(
result
.
Bytes
())
)
require
.
NoError
(
t
,
err
)
sb
.
txs
.
recoverV
(
chainID
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment