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
67e21e8c
Unverified
Commit
67e21e8c
authored
Apr 10, 2023
by
Michael de Hoog
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup
parent
a34a46aa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
32 deletions
+31
-32
driver.go
op-batcher/batcher/driver.go
+27
-28
txmgr.go
op-service/txmgr/txmgr.go
+4
-4
No files found.
op-batcher/batcher/driver.go
View file @
67e21e8c
...
@@ -300,6 +300,14 @@ func (l *BatchSubmitter) loop() {
...
@@ -300,6 +300,14 @@ func (l *BatchSubmitter) loop() {
publishTicker
:=
time
.
NewTicker
(
100
*
time
.
Millisecond
)
publishTicker
:=
time
.
NewTicker
(
100
*
time
.
Millisecond
)
defer
publishTicker
.
Stop
()
defer
publishTicker
.
Stop
()
receiptsCh
:=
make
(
chan
txReceipt
)
receiptsCh
:=
make
(
chan
txReceipt
)
receiptHandler
:=
func
(
r
txReceipt
)
{
// Record TX Status
if
r
.
err
!=
nil
{
l
.
recordFailedTx
(
r
.
id
,
r
.
err
)
}
else
{
l
.
recordConfirmedTx
(
r
.
id
,
r
.
receipt
)
}
}
for
{
for
{
select
{
select
{
...
@@ -307,21 +315,16 @@ func (l *BatchSubmitter) loop() {
...
@@ -307,21 +315,16 @@ func (l *BatchSubmitter) loop() {
l
.
loadBlocksIntoState
(
l
.
shutdownCtx
)
l
.
loadBlocksIntoState
(
l
.
shutdownCtx
)
case
<-
publishTicker
.
C
:
case
<-
publishTicker
.
C
:
_
=
l
.
publishStateToL1
(
l
.
killCtx
,
receiptsCh
)
_
=
l
.
publishStateToL1
(
l
.
killCtx
,
receiptsCh
)
case
res
:=
<-
receiptsCh
:
case
r
:=
<-
receiptsCh
:
// Record TX Status
receiptHandler
(
r
)
if
res
.
err
!=
nil
{
l
.
recordFailedTx
(
res
.
id
,
res
.
err
)
}
else
{
l
.
recordConfirmedTx
(
res
.
id
,
res
.
receipt
)
}
case
<-
l
.
shutdownCtx
.
Done
()
:
case
<-
l
.
shutdownCtx
.
Done
()
:
l
.
drainState
(
receiptsCh
)
l
.
drainState
(
receiptsCh
,
receiptHandler
)
return
return
}
}
}
}
}
}
func
(
l
*
BatchSubmitter
)
drainState
(
receiptsCh
chan
txReceipt
)
{
func
(
l
*
BatchSubmitter
)
drainState
(
receiptsCh
chan
txReceipt
,
receiptHandler
func
(
res
txReceipt
)
)
{
err
:=
l
.
state
.
Close
()
err
:=
l
.
state
.
Close
()
if
err
!=
nil
{
if
err
!=
nil
{
l
.
log
.
Error
(
"error closing the channel manager"
,
"err"
,
err
)
l
.
log
.
Error
(
"error closing the channel manager"
,
"err"
,
err
)
...
@@ -343,27 +346,23 @@ func (l *BatchSubmitter) drainState(receiptsCh chan txReceipt) {
...
@@ -343,27 +346,23 @@ func (l *BatchSubmitter) drainState(receiptsCh chan txReceipt) {
}
}
}
}
}()
}()
var
receipts
[]
txReceipt
receipts
Done
:=
make
(
chan
struct
{})
tx
Done
:=
make
(
chan
struct
{})
go
func
()
{
go
func
()
{
for
{
// wait for all transactions to complete
select
{
l
.
txWg
.
Wait
()
case
res
:=
<-
receiptsCh
:
close
(
txDone
)
receipts
=
append
(
receipts
,
res
)
case
<-
receiptsDone
:
return
}
}
}()
}()
// wait for all transactions to complete
// handle the remaining receipts
l
.
txWg
.
Wait
()
for
{
close
(
receiptsDone
)
select
{
// process the receipts
case
r
:=
<-
receiptsCh
:
for
_
,
res
:=
range
receipts
{
receiptHandler
(
r
)
if
res
.
err
!=
nil
{
case
<-
txDone
:
l
.
recordFailedTx
(
res
.
id
,
res
.
err
)
for
len
(
receiptsCh
)
>
0
{
}
else
{
receiptHandler
(
<-
receiptsCh
)
l
.
recordConfirmedTx
(
res
.
id
,
res
.
receipt
)
}
return
}
}
}
}
}
}
...
...
op-service/txmgr/txmgr.go
View file @
67e21e8c
...
@@ -159,7 +159,7 @@ func (m *SimpleTxManager) reset() {
...
@@ -159,7 +159,7 @@ func (m *SimpleTxManager) reset() {
return
return
}
}
close
(
m
.
r
esetChannel
())
close
(
m
.
getR
esetChannel
())
m
.
wg
.
Wait
()
m
.
wg
.
Wait
()
m
.
lock
.
Lock
()
m
.
lock
.
Lock
()
...
@@ -170,9 +170,9 @@ func (m *SimpleTxManager) reset() {
...
@@ -170,9 +170,9 @@ func (m *SimpleTxManager) reset() {
m
.
resetting
.
Store
(
false
)
m
.
resetting
.
Store
(
false
)
}
}
//
r
esetChannel is a thread-safe getter for the channel that is closed upon
//
getR
esetChannel is a thread-safe getter for the channel that is closed upon
// transaction manager resets.
// transaction manager resets.
func
(
m
*
SimpleTxManager
)
r
esetChannel
()
chan
struct
{}
{
func
(
m
*
SimpleTxManager
)
getR
esetChannel
()
chan
struct
{}
{
m
.
lock
.
RLock
()
m
.
lock
.
RLock
()
defer
m
.
lock
.
RUnlock
()
defer
m
.
lock
.
RUnlock
()
return
m
.
resetC
return
m
.
resetC
...
@@ -294,7 +294,7 @@ func (m *SimpleTxManager) sendTx(ctx context.Context, tx *types.Transaction) (*t
...
@@ -294,7 +294,7 @@ func (m *SimpleTxManager) sendTx(ctx context.Context, tx *types.Transaction) (*t
ticker
:=
time
.
NewTicker
(
m
.
cfg
.
ResubmissionTimeout
)
ticker
:=
time
.
NewTicker
(
m
.
cfg
.
ResubmissionTimeout
)
defer
ticker
.
Stop
()
defer
ticker
.
Stop
()
resetChan
:=
m
.
r
esetChannel
()
resetChan
:=
m
.
getR
esetChannel
()
bumpCounter
:=
0
bumpCounter
:=
0
for
{
for
{
...
...
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