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
30fdff6f
Commit
30fdff6f
authored
Mar 07, 2023
by
Joshua Gutow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-node/derivation: JSON Encoding for Frames
parent
1786f370
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
7 deletions
+19
-7
frame.go
op-node/rollup/derive/frame.go
+4
-4
params.go
op-node/rollup/derive/params.go
+15
-3
No files found.
op-node/rollup/derive/frame.go
View file @
30fdff6f
...
@@ -24,10 +24,10 @@ const MaxFrameLen = 1_000_000
...
@@ -24,10 +24,10 @@ const MaxFrameLen = 1_000_000
// is_last = bool
// is_last = bool
type
Frame
struct
{
type
Frame
struct
{
ID
ChannelID
ID
ChannelID
`json:"id"`
FrameNumber
uint16
FrameNumber
uint16
`json:"frame_number"`
Data
[]
byte
Data
[]
byte
`json:"data"`
IsLast
bool
IsLast
bool
`'json:"is_last"`
}
}
// MarshalBinary writes the frame to `w`.
// MarshalBinary writes the frame to `w`.
...
...
op-node/rollup/derive/params.go
View file @
30fdff6f
package
derive
package
derive
import
(
import
(
"encoding/
json
"
"encoding/
hex
"
"errors"
"errors"
"fmt"
"fmt"
)
)
...
@@ -46,6 +46,18 @@ func (id ChannelID) TerminalString() string {
...
@@ -46,6 +46,18 @@ func (id ChannelID) TerminalString() string {
return
fmt
.
Sprintf
(
"%x..%x"
,
id
[
:
3
],
id
[
13
:
])
return
fmt
.
Sprintf
(
"%x..%x"
,
id
[
:
3
],
id
[
13
:
])
}
}
func
(
id
ChannelID
)
MarshalJSON
()
([]
byte
,
error
)
{
func
(
id
ChannelID
)
MarshalText
()
([]
byte
,
error
)
{
return
json
.
Marshal
(
id
.
String
())
return
[]
byte
(
id
.
String
()),
nil
}
func
(
id
*
ChannelID
)
UnmarshalText
(
text
[]
byte
)
error
{
h
,
err
:=
hex
.
DecodeString
(
string
(
text
))
if
err
!=
nil
{
return
err
}
if
len
(
h
)
!=
ChannelIDLength
{
return
errors
.
New
(
"invalid length"
)
}
copy
(
id
[
:
],
h
)
return
nil
}
}
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