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
abd7a807
Commit
abd7a807
authored
Jan 25, 2023
by
Sebastian Stammler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-batcher: Improve documentation regarding full channels
parent
11a1976f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
10 deletions
+18
-10
channel_builder.go
op-batcher/batcher/channel_builder.go
+18
-10
No files found.
op-batcher/batcher/channel_builder.go
View file @
abd7a807
...
@@ -71,6 +71,8 @@ var (
...
@@ -71,6 +71,8 @@ var (
ErrMaxFrameIndex
=
errors
.
New
(
"max frame index reached (uint16)"
)
ErrMaxFrameIndex
=
errors
.
New
(
"max frame index reached (uint16)"
)
)
)
// InputThreshold calculates the input data threshold in bytes from the given
// parameters.
func
(
c
ChannelConfig
)
InputThreshold
()
uint64
{
func
(
c
ChannelConfig
)
InputThreshold
()
uint64
{
return
uint64
(
float64
(
c
.
TargetNumFrames
)
*
float64
(
c
.
TargetFrameSize
)
/
c
.
ApproxComprRatio
)
return
uint64
(
float64
(
c
.
TargetNumFrames
)
*
float64
(
c
.
TargetFrameSize
)
/
c
.
ApproxComprRatio
)
}
}
...
@@ -102,15 +104,12 @@ func (c *channelBuilder) Reset() error {
...
@@ -102,15 +104,12 @@ func (c *channelBuilder) Reset() error {
return
c
.
co
.
Reset
()
return
c
.
co
.
Reset
()
}
}
// AddBlock adds a block to the channel compression pipeline. I
nputTargetReached
// AddBlock adds a block to the channel compression pipeline. I
sFull should be
//
should be called aftewards to test whether the target input data amount has
//
called aftewards to test whether the channel is full. If full, a new channel
//
been reached. In this case, a new channel
must be started.
// must be started.
//
//
// AddBlock returns ErrInputTargetReached if called despite having reached the
// AddBlock returns a ChannelFullError if called even though the channel is
// input data target.
// already full. See description of FullErr for details.
// It returns ErrTooManyRLPBytes if the channel cannot take more input
// data. Then, too, a new channel has to be started.
// It returns
//
//
// Call OutputFrames() afterwards to create frames.
// Call OutputFrames() afterwards to create frames.
func
(
c
*
channelBuilder
)
AddBlock
(
block
*
types
.
Block
)
error
{
func
(
c
*
channelBuilder
)
AddBlock
(
block
*
types
.
Block
)
error
{
...
@@ -143,11 +142,20 @@ func (c *channelBuilder) InputTargetReached() bool {
...
@@ -143,11 +142,20 @@ func (c *channelBuilder) InputTargetReached() bool {
}
}
// IsFull returns whether the channel is full.
// IsFull returns whether the channel is full.
// FullErr returns the reason for the channel being full.
func
(
c
*
channelBuilder
)
IsFull
()
bool
{
func
(
c
*
channelBuilder
)
IsFull
()
bool
{
return
c
.
fullErr
!=
nil
return
c
.
fullErr
!=
nil
}
}
// FullErr returns the reason why the channel is full.
// FullErr returns the reason why the channel is full. If not full yet, it
// returns nil.
//
// It returns a ChannelFullError wrapping one of three possible reasons for the
// channel being full:
// - ErrInputTargetReached if the target amount of input data has been reached,
// - derive.MaxRLPBytesPerChannel if the general maximum amount of input data
// would have been exceeded by the latest AddBlock call,
// - ErrMaxFrameIndex if the maximum number of frames has been generated (uint16)
func
(
c
*
channelBuilder
)
FullErr
()
error
{
func
(
c
*
channelBuilder
)
FullErr
()
error
{
return
c
.
fullErr
return
c
.
fullErr
}
}
...
@@ -243,7 +251,7 @@ func (c *channelBuilder) NumFrames() int {
...
@@ -243,7 +251,7 @@ func (c *channelBuilder) NumFrames() int {
}
}
// NextFrame returns the next available frame.
// NextFrame returns the next available frame.
// HasFrame must be called prio to check if there's a next frame available.
// HasFrame must be called prio
r
to check if there's a next frame available.
// Panics if called when there's no next frame.
// Panics if called when there's no next frame.
func
(
c
*
channelBuilder
)
NextFrame
()
(
txID
,
[]
byte
)
{
func
(
c
*
channelBuilder
)
NextFrame
()
(
txID
,
[]
byte
)
{
if
len
(
c
.
frames
)
==
0
{
if
len
(
c
.
frames
)
==
0
{
...
...
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