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
51178b3d
Unverified
Commit
51178b3d
authored
Apr 12, 2023
by
protolambda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-program: kv-store style change replace os.Is(Not)Exist with errors.Is call
parent
472ea471
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
disk.go
op-program/host/kvstore/disk.go
+3
-2
No files found.
op-program/host/kvstore/disk.go
View file @
51178b3d
...
@@ -2,6 +2,7 @@ package kvstore
...
@@ -2,6 +2,7 @@ package kvstore
import
(
import
(
"encoding/hex"
"encoding/hex"
"errors"
"fmt"
"fmt"
"io"
"io"
"os"
"os"
...
@@ -32,7 +33,7 @@ func (d *DiskKV) pathKey(k common.Hash) string {
...
@@ -32,7 +33,7 @@ func (d *DiskKV) pathKey(k common.Hash) string {
func
(
d
*
DiskKV
)
Put
(
k
common
.
Hash
,
v
[]
byte
)
error
{
func
(
d
*
DiskKV
)
Put
(
k
common
.
Hash
,
v
[]
byte
)
error
{
f
,
err
:=
os
.
OpenFile
(
d
.
pathKey
(
k
),
os
.
O_WRONLY
|
os
.
O_CREATE
|
os
.
O_EXCL
|
os
.
O_TRUNC
,
diskPermission
)
f
,
err
:=
os
.
OpenFile
(
d
.
pathKey
(
k
),
os
.
O_WRONLY
|
os
.
O_CREATE
|
os
.
O_EXCL
|
os
.
O_TRUNC
,
diskPermission
)
if
err
!=
nil
{
if
err
!=
nil
{
if
os
.
IsExist
(
err
)
{
if
errors
.
Is
(
err
,
os
.
ErrExist
)
{
return
ErrAlreadyExists
return
ErrAlreadyExists
}
}
return
fmt
.
Errorf
(
"failed to open new pre-image file %s: %w"
,
k
,
err
)
return
fmt
.
Errorf
(
"failed to open new pre-image file %s: %w"
,
k
,
err
)
...
@@ -50,7 +51,7 @@ func (d *DiskKV) Put(k common.Hash, v []byte) error {
...
@@ -50,7 +51,7 @@ func (d *DiskKV) Put(k common.Hash, v []byte) error {
func
(
d
*
DiskKV
)
Get
(
k
common
.
Hash
)
([]
byte
,
error
)
{
func
(
d
*
DiskKV
)
Get
(
k
common
.
Hash
)
([]
byte
,
error
)
{
f
,
err
:=
os
.
OpenFile
(
d
.
pathKey
(
k
),
os
.
O_RDONLY
,
diskPermission
)
f
,
err
:=
os
.
OpenFile
(
d
.
pathKey
(
k
),
os
.
O_RDONLY
,
diskPermission
)
if
err
!=
nil
{
if
err
!=
nil
{
if
os
.
IsNotExist
(
err
)
{
if
errors
.
Is
(
err
,
os
.
ErrNotExist
)
{
return
nil
,
ErrNotFound
return
nil
,
ErrNotFound
}
}
return
nil
,
fmt
.
Errorf
(
"failed to open pre-image file %s: %w"
,
k
,
err
)
return
nil
,
fmt
.
Errorf
(
"failed to open pre-image file %s: %w"
,
k
,
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