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
334a6a88
Commit
334a6a88
authored
Mar 17, 2023
by
Andreas Bigger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move fixed overhead into a const
⚙
parent
d58eb90b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
channel_out.go
op-node/rollup/derive/channel_out.go
+8
-6
No files found.
op-node/rollup/derive/channel_out.go
View file @
334a6a88
...
...
@@ -18,6 +18,11 @@ var ErrMaxFrameSizeTooSmall = errors.New("maxSize is too small to fit the fixed
var
ErrNotDepositTx
=
errors
.
New
(
"first transaction in block is not a deposit tx"
)
var
ErrTooManyRLPBytes
=
errors
.
New
(
"batch would cause RLP bytes to go over limit"
)
// FrameV0OverHeadSize is the absolute minimum size of a frame.
// This is the fixed overhead frame size,
// calculated as follows: 16 + 2 + 4 + 1 = 23 bytes.
const
FrameV0OverHeadSize
=
23
type
ChannelOut
struct
{
id
ChannelID
// Frame ID of the next frame to emit. Increment after emitting
...
...
@@ -151,16 +156,13 @@ func (co *ChannelOut) OutputFrame(w *bytes.Buffer, maxSize uint64) (uint16, erro
FrameNumber
:
uint16
(
co
.
frame
),
}
// Error if the `maxSize` is too small to fit the fixed frame
// overhead as specified below.
if
maxSize
<
23
{
// Error if the `maxSize` is smaller than the [FrameV0OverHeadSize].
if
maxSize
<
FrameV0OverHeadSize
{
return
0
,
ErrMaxFrameSizeTooSmall
}
// Copy data from the local buffer into the frame data buffer
// Don't go past the maxSize with the fixed frame overhead.
// Fixed overhead: 16 + 2 + 4 + 1 = 23 bytes.
maxDataSize
:=
maxSize
-
23
maxDataSize
:=
maxSize
-
FrameV0OverHeadSize
if
maxDataSize
>
uint64
(
co
.
buf
.
Len
())
{
maxDataSize
=
uint64
(
co
.
buf
.
Len
())
// If we are closed & will not spill past the current frame
...
...
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