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
acc22d76
Unverified
Commit
acc22d76
authored
Mar 24, 2023
by
Brian Bland
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address PR feedback, improve context naming and simplify selects
parent
decf9825
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
34 deletions
+16
-34
channel_manager.go
op-batcher/batcher/channel_manager.go
+3
-2
driver.go
op-batcher/batcher/driver.go
+13
-32
No files found.
op-batcher/batcher/channel_manager.go
View file @
acc22d76
...
...
@@ -358,8 +358,9 @@ func l2BlockRefFromBlockAndL1Info(block *types.Block, l1info derive.L1BlockInfo)
// Close closes the current pending channel, if one exists, and prevents the
// creation of any new channels.
// This ensures that no new frames will be produced, but there may be any number
// of pending frames produced before this call which should still be published.
// This ensures that no new blocks will be added to the channel, but there may be any number
// of frames still produced by calling `OutputFrames()`, which flushes the compression buffer.
// These frames still need to be published.
func
(
s
*
channelManager
)
Close
()
{
if
s
.
closed
{
return
...
...
op-batcher/batcher/driver.go
View file @
acc22d76
...
...
@@ -27,12 +27,11 @@ type BatchSubmitter struct {
txMgr
txmgr
.
TxManager
wg
sync
.
WaitGroup
done
chan
struct
{}
loadCtx
context
.
Context
cancel
Load
context
.
CancelFunc
txCtx
context
.
Context
cancel
Tx
context
.
CancelFunc
shutdownCtx
context
.
Context
cancel
ShutdownCtx
context
.
CancelFunc
killCtx
context
.
Context
cancel
KillCtx
context
.
CancelFunc
mutex
sync
.
Mutex
running
bool
...
...
@@ -146,9 +145,8 @@ func (l *BatchSubmitter) Start() error {
}
l
.
running
=
true
l
.
done
=
make
(
chan
struct
{})
l
.
loadCtx
,
l
.
cancelLoad
=
context
.
WithCancel
(
context
.
Background
())
l
.
txCtx
,
l
.
cancelTx
=
context
.
WithCancel
(
context
.
Background
())
l
.
shutdownCtx
,
l
.
cancelShutdownCtx
=
context
.
WithCancel
(
context
.
Background
())
l
.
killCtx
,
l
.
cancelKillCtx
=
context
.
WithCancel
(
context
.
Background
())
l
.
state
.
Clear
()
l
.
lastStoredBlock
=
eth
.
BlockID
{}
...
...
@@ -175,18 +173,9 @@ func (l *BatchSubmitter) Stop(ctx context.Context) error {
}
l
.
running
=
false
// go routine will call cancelTx() if the passed in ctx is ever Done
cancelTx
:=
l
.
cancelTx
wrapped
,
cancel
:=
context
.
WithCancel
(
ctx
)
defer
cancel
()
go
func
()
{
<-
wrapped
.
Done
()
cancelTx
()
}()
l
.
cancelLoad
()
close
(
l
.
done
)
l
.
cancelShutdownCtx
()
l
.
wg
.
Wait
()
l
.
cancelKillCtx
()
l
.
log
.
Info
(
"Batch Submitter stopped"
)
...
...
@@ -302,18 +291,10 @@ func (l *BatchSubmitter) loop() {
for
{
select
{
case
<-
ticker
.
C
:
// prioritize the `done` condition over the ticker, even though select ordering is randomized
select
{
case
<-
l
.
done
:
l
.
publishStateToL1
(
l
.
txCtx
)
return
default
:
}
l
.
loadBlocksIntoState
(
l
.
loadCtx
)
l
.
publishStateToL1
(
l
.
txCtx
)
case
<-
l
.
done
:
l
.
publishStateToL1
(
l
.
txCtx
)
l
.
loadBlocksIntoState
(
l
.
shutdownCtx
)
l
.
publishStateToL1
(
l
.
killCtx
)
case
<-
l
.
shutdownCtx
.
Done
()
:
l
.
publishStateToL1
(
l
.
killCtx
)
return
}
}
...
...
@@ -328,7 +309,7 @@ func (l *BatchSubmitter) publishStateToL1(ctx context.Context) {
select
{
case
<-
ctx
.
Done
()
:
l
.
state
.
Close
()
case
<-
l
.
done
:
case
<-
l
.
shutdownCtx
.
Done
()
:
l
.
state
.
Close
()
default
:
}
...
...
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