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
a370ecf3
Unverified
Commit
a370ecf3
authored
Jun 23, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-node: Close file before renaming.
Improve commenting/organisation.
parent
4352684f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
4 deletions
+7
-4
flags.go
op-node/flags/flags.go
+2
-2
config_persistence.go
op-node/node/config_persistence.go
+5
-2
No files found.
op-node/flags/flags.go
View file @
a370ecf3
...
...
@@ -54,6 +54,8 @@ var (
Usage
:
"RPC listening port"
,
EnvVars
:
prefixEnvVars
(
"RPC_PORT"
),
}
/* Optional Flags */
RPCEnableAdmin
=
&
cli
.
BoolFlag
{
Name
:
"rpc.enable-admin"
,
Usage
:
"Enable the admin API (experimental)"
,
...
...
@@ -64,8 +66,6 @@ var (
Usage
:
"File path used to persist state changes made via the admin API so they persist across restarts"
,
EnvVars
:
prefixEnvVars
(
"RPC_ADMIN_STATE"
),
}
/* Optional Flags */
L1TrustRPC
=
&
cli
.
BoolFlag
{
Name
:
"l1.trustrpc"
,
Usage
:
"Trust the L1 RPC, sync faster at risk of malicious/buggy RPC providing bad or inconsistent L1 data"
,
...
...
op-node/node/config_persistence.go
View file @
a370ecf3
...
...
@@ -69,7 +69,7 @@ func (p *ActiveConfigPersistence) persist(sequencerStarted bool) error {
if
err
!=
nil
{
return
fmt
.
Errorf
(
"open file (%v) for writing: %w"
,
tmpFile
,
err
)
}
defer
file
.
Close
()
defer
file
.
Close
()
// Ensure file is closed even if write or sync fails
_
,
err
=
file
.
Write
(
data
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"write new config to temp file (%v): %w"
,
tmpFile
,
err
)
...
...
@@ -77,7 +77,9 @@ func (p *ActiveConfigPersistence) persist(sequencerStarted bool) error {
if
err
:=
file
.
Sync
();
err
!=
nil
{
return
fmt
.
Errorf
(
"sync new config temp file (%v): %w"
,
tmpFile
,
err
)
}
if
err
:=
file
.
Close
();
err
!=
nil
{
return
fmt
.
Errorf
(
"close new config temp file (%v): %w"
,
tmpFile
,
err
)
}
// Rename to replace the previous file
if
err
:=
os
.
Rename
(
tmpFile
,
p
.
file
);
err
!=
nil
{
return
fmt
.
Errorf
(
"rename temp config file to final destination: %w"
,
err
)
...
...
@@ -105,6 +107,7 @@ func (p *ActiveConfigPersistence) read() (persistedState, error) {
defer
p
.
lock
.
Unlock
()
data
,
err
:=
os
.
ReadFile
(
p
.
file
)
if
errors
.
Is
(
err
,
os
.
ErrNotExist
)
{
// persistedState.SequencerStarted == nil: SequencerState() will return StateUnset if no state is found
return
persistedState
{},
nil
}
else
if
err
!=
nil
{
return
persistedState
{},
fmt
.
Errorf
(
"read config file (%v): %w"
,
p
.
file
,
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