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
e03b5073
Commit
e03b5073
authored
Feb 04, 2023
by
Sebastian Stammler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-batcher: Reorder channel builder types
parent
8d5109e7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
66 deletions
+64
-66
channel_builder.go
op-batcher/batcher/channel_builder.go
+64
-66
No files found.
op-batcher/batcher/channel_builder.go
View file @
e03b5073
...
...
@@ -11,28 +11,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
)
type
(
// channelBuilder uses a ChannelOut to create a channel with output frame
// size approximation.
channelBuilder
struct
{
cfg
ChannelConfig
// L1 block timestamp of combined channel & sequencing window timeout. 0 if
// no timeout set yet.
timeout
uint64
// marked as full if a) max RLP input bytes, b) max num frames or c) max
// allowed frame index (uint16) has been reached
fullErr
error
// current channel
co
*
derive
.
ChannelOut
// list of blocks in the channel. Saved in case the channel must be rebuilt
blocks
[]
*
types
.
Block
// frames data queue, to be send as txs
frames
[]
taggedData
}
ChannelConfig
struct
{
type
ChannelConfig
struct
{
// Number of epochs (L1 blocks) per sequencing window, including the epoch
// L1 origin block itself
SeqWindowSize
uint64
...
...
@@ -58,33 +37,34 @@ type (
// average from experiments to avoid the chances of creating a small
// additional leftover frame.
ApproxComprRatio
float64
}
ChannelFullError
struct
{
Err
error
}
)
func
(
e
*
ChannelFullError
)
Error
()
string
{
return
"channel full: "
+
e
.
Err
.
Error
()
}
func
(
e
*
ChannelFullError
)
Unwrap
()
error
{
return
e
.
Err
}
var
(
ErrInputTargetReached
=
errors
.
New
(
"target amount of input data reached"
)
ErrMaxFrameIndex
=
errors
.
New
(
"max frame index reached (uint16)"
)
ErrChannelTimedOut
=
errors
.
New
(
"channel timed out"
)
)
// InputThreshold calculates the input data threshold in bytes from the given
// parameters.
func
(
c
ChannelConfig
)
InputThreshold
()
uint64
{
return
uint64
(
float64
(
c
.
TargetNumFrames
)
*
float64
(
c
.
TargetFrameSize
)
/
c
.
ApproxComprRatio
)
}
// channelBuilder uses a ChannelOut to create a channel with output frame
// size approximation.
type
channelBuilder
struct
{
cfg
ChannelConfig
// L1 block timestamp of combined channel & sequencing window timeout. 0 if
// no timeout set yet.
timeout
uint64
// marked as full if a) max RLP input bytes, b) max num frames or c) max
// allowed frame index (uint16) has been reached
fullErr
error
// current channel
co
*
derive
.
ChannelOut
// list of blocks in the channel. Saved in case the channel must be rebuilt
blocks
[]
*
types
.
Block
// frames data queue, to be send as txs
frames
[]
taggedData
}
func
newChannelBuilder
(
cfg
ChannelConfig
)
(
*
channelBuilder
,
error
)
{
co
,
err
:=
derive
.
NewChannelOut
()
if
err
!=
nil
{
...
...
@@ -336,3 +316,21 @@ func (c *channelBuilder) PushFrame(id txID, frame []byte) {
}
c
.
frames
=
append
(
c
.
frames
,
taggedData
{
id
:
id
,
data
:
frame
})
}
var
(
ErrInputTargetReached
=
errors
.
New
(
"target amount of input data reached"
)
ErrMaxFrameIndex
=
errors
.
New
(
"max frame index reached (uint16)"
)
ErrChannelTimedOut
=
errors
.
New
(
"channel timed out"
)
)
type
ChannelFullError
struct
{
Err
error
}
func
(
e
*
ChannelFullError
)
Error
()
string
{
return
"channel full: "
+
e
.
Err
.
Error
()
}
func
(
e
*
ChannelFullError
)
Unwrap
()
error
{
return
e
.
Err
}
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