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
b2a588e3
Commit
b2a588e3
authored
Oct 12, 2023
by
Joshua Gutow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-node: Clarify function name & comments
parent
58d7067d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
channel_bank.go
op-node/rollup/derive/channel_bank.go
+8
-6
No files found.
op-node/rollup/derive/channel_bank.go
View file @
b2a588e3
...
...
@@ -117,11 +117,12 @@ func (cb *ChannelBank) IngestFrame(f Frame) {
// Read the raw data of the first channel, if it's timed-out or closed.
// Read returns io.EOF if there is nothing new to read.
func
(
cb
*
ChannelBank
)
Read
()
(
data
[]
byte
,
err
error
)
{
// Common Code. By returning `nil,nil`, we call back into this to make sure that all timed
// out channels at the front of the queue will eventually be removed.
// Common Code pre/post canyon. Return io.EOF if no channels
if
len
(
cb
.
channelQueue
)
==
0
{
return
nil
,
io
.
EOF
}
// Return nil,nil on the first channel if it is timed out. There may be more timed out
// channels at the head of the queue and we want to remove them all.
first
:=
cb
.
channelQueue
[
0
]
ch
:=
cb
.
channels
[
first
]
timedOut
:=
ch
.
OpenBlockNumber
()
+
cb
.
cfg
.
ChannelTimeout
<
cb
.
Origin
()
.
Number
...
...
@@ -137,22 +138,23 @@ func (cb *ChannelBank) Read() (data []byte, err error) {
// Pre-Canyon we simply check the first index.
// Post-Canyon we read the entire channelQueue for the first ready channel. If no channel is
// available, we return `nil, io.EOF`.
// Canyon is activated when the first L1 block whose time >= CanyonTime, not on the L2 timestamp.
if
!
cb
.
cfg
.
IsCanyon
(
cb
.
Origin
()
.
Time
)
{
return
cb
.
read
Index
(
0
)
return
cb
.
tryReadChannelAt
Index
(
0
)
}
for
i
:=
0
;
i
<
len
(
cb
.
channelQueue
);
i
++
{
if
data
,
err
:=
cb
.
read
Index
(
i
);
err
==
nil
{
if
data
,
err
:=
cb
.
tryReadChannelAt
Index
(
i
);
err
==
nil
{
return
data
,
nil
}
}
return
nil
,
io
.
EOF
}
//
read
Index attempts to read the channel at the specified index. If the channel is
//
tryReadChannelAt
Index attempts to read the channel at the specified index. If the channel is
// not ready (or timed out), it will return io.EOF.
// If the channel read was successful, it will remove the channel from the channelQueue.
func
(
cb
*
ChannelBank
)
read
Index
(
i
int
)
(
data
[]
byte
,
err
error
)
{
func
(
cb
*
ChannelBank
)
tryReadChannelAt
Index
(
i
int
)
(
data
[]
byte
,
err
error
)
{
chanID
:=
cb
.
channelQueue
[
i
]
ch
:=
cb
.
channels
[
chanID
]
timedOut
:=
ch
.
OpenBlockNumber
()
+
cb
.
cfg
.
ChannelTimeout
<
cb
.
Origin
()
.
Number
...
...
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