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
648392e0
Commit
648392e0
authored
Jun 23, 2021
by
Mark Tyneway
Committed by
Liam Horne
Jun 29, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
l2geth: sync service retries connection to remote server
parent
7c6fa5b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
8 deletions
+15
-8
sync_service.go
l2geth/rollup/sync_service.go
+15
-8
No files found.
l2geth/rollup/sync_service.go
View file @
648392e0
...
@@ -128,22 +128,29 @@ func NewSyncService(ctx context.Context, cfg Config, txpool *core.TxPool, bc *co
...
@@ -128,22 +128,29 @@ func NewSyncService(ctx context.Context, cfg Config, txpool *core.TxPool, bc *co
// requirement of the remote server being up.
// requirement of the remote server being up.
if
service
.
enable
{
if
service
.
enable
{
// Ensure that the rollup client can connect to a remote server
// Ensure that the rollup client can connect to a remote server
// before starting.
// before starting. Retry until it can connect.
err
:=
service
.
ensureClient
()
t1
:=
time
.
NewTicker
(
10
*
time
.
Second
)
if
err
!=
nil
{
for
;
true
;
<-
t1
.
C
{
return
nil
,
fmt
.
Errorf
(
"Rollup client unable to connect: %w"
,
err
)
err
:=
service
.
ensureClient
()
if
err
!=
nil
{
log
.
Info
(
"Cannot connect to upstream service"
,
"msg"
,
err
)
}
else
{
log
.
Info
(
"Connected to upstream service"
)
t1
.
Stop
()
break
}
}
}
// Wait until the remote service is done syncing
// Wait until the remote service is done syncing
t
:=
time
.
NewTicker
(
10
*
time
.
Second
)
t
2
:=
time
.
NewTicker
(
10
*
time
.
Second
)
for
;
true
;
<-
t
.
C
{
for
;
true
;
<-
t
2
.
C
{
status
,
err
:=
service
.
client
.
SyncStatus
(
service
.
backend
)
status
,
err
:=
service
.
client
.
SyncStatus
(
service
.
backend
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Error
(
"Cannot get sync status"
)
log
.
Error
(
"Cannot get sync status"
)
continue
continue
}
}
if
!
status
.
Syncing
{
if
!
status
.
Syncing
{
t
.
Stop
()
t
2
.
Stop
()
break
break
}
}
log
.
Info
(
"Still syncing"
,
"index"
,
status
.
CurrentTransactionIndex
,
"tip"
,
status
.
HighestKnownTransactionIndex
)
log
.
Info
(
"Still syncing"
,
"index"
,
status
.
CurrentTransactionIndex
,
"tip"
,
status
.
HighestKnownTransactionIndex
)
...
@@ -153,7 +160,7 @@ func NewSyncService(ctx context.Context, cfg Config, txpool *core.TxPool, bc *co
...
@@ -153,7 +160,7 @@ func NewSyncService(ctx context.Context, cfg Config, txpool *core.TxPool, bc *co
// it happens before the RPC endpoints open up
// it happens before the RPC endpoints open up
// Only do it if the sync service is enabled so that this
// Only do it if the sync service is enabled so that this
// can be ran without needing to have a configured RollupClient.
// can be ran without needing to have a configured RollupClient.
err
=
service
.
initializeLatestL1
(
cfg
.
CanonicalTransactionChainDeployHeight
)
err
:
=
service
.
initializeLatestL1
(
cfg
.
CanonicalTransactionChainDeployHeight
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Cannot initialize latest L1 data: %w"
,
err
)
return
nil
,
fmt
.
Errorf
(
"Cannot initialize latest L1 data: %w"
,
err
)
}
}
...
...
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