Skip to content

Commit ad31b75

Browse files
committed
Move wasm-only code into wasm build flags
1 parent 7e7d4ff commit ad31b75

File tree

4 files changed

+88
-15
lines changed

4 files changed

+88
-15
lines changed

core/rawdb/accessors_snapshot.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,10 @@ package rawdb
1818

1919
import (
2020
"encoding/binary"
21-
"errors"
2221

23-
"github.com/cockroachdb/pebble"
2422
"github.com/ethereum/go-ethereum/common"
2523
"github.com/ethereum/go-ethereum/ethdb"
26-
"github.com/ethereum/go-ethereum/ethdb/memorydb"
2724
"github.com/ethereum/go-ethereum/log"
28-
"github.com/syndtr/goleveldb/leveldb"
2925
)
3026

3127
// ReadSnapshotDisabled retrieves if the snapshot maintenance is disabled.
@@ -76,17 +72,6 @@ func DeleteSnapshotRoot(db ethdb.KeyValueWriter) {
7672
}
7773
}
7874

79-
func isDbErrNotFound(err error) bool {
80-
return errors.Is(err, leveldb.ErrNotFound) || errors.Is(err, pebble.ErrNotFound) || errors.Is(err, memorydb.ErrMemorydbNotFound)
81-
}
82-
83-
func ignoreNotFound(blob []byte, err error) ([]byte, error) {
84-
if isDbErrNotFound(err) {
85-
return nil, nil
86-
}
87-
return blob, err
88-
}
89-
9075
// ReadAccountSnapshot retrieves the snapshot entry of an account trie leaf.
9176
func ReadAccountSnapshot(db ethdb.KeyValueReader, hash common.Hash) ([]byte, error) {
9277
return ignoreNotFound(db.Get(accountSnapshotKey(hash)))

core/rawdb/arbitrum_not_found.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2024 The go-ethereum Authors
2+
// This file is part of the go-ethereum library.
3+
//
4+
// The go-ethereum library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Lesser General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// The go-ethereum library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Lesser General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Lesser General Public License
15+
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
16+
17+
package rawdb
18+
19+
// Arbitrum specific code to handle database errors
20+
21+
func ignoreNotFound(blob []byte, err error) ([]byte, error) {
22+
if isDbErrNotFound(err) {
23+
return nil, nil
24+
}
25+
return blob, err
26+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2024 The go-ethereum Authors
2+
// This file is part of the go-ethereum library.
3+
//
4+
// The go-ethereum library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Lesser General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// The go-ethereum library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Lesser General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Lesser General Public License
15+
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
16+
17+
//go:build !wasm
18+
// +build !wasm
19+
20+
package rawdb
21+
22+
import (
23+
"errors"
24+
25+
"github.com/cockroachdb/pebble"
26+
"github.com/ethereum/go-ethereum/ethdb/memorydb"
27+
"github.com/syndtr/goleveldb/leveldb"
28+
)
29+
30+
func isDbErrNotFound(err error) bool {
31+
return errors.Is(err, leveldb.ErrNotFound) || errors.Is(err, pebble.ErrNotFound) || errors.Is(err, memorydb.ErrMemorydbNotFound)
32+
}

core/rawdb/arbitrum_not_found_wasm.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2024 The go-ethereum Authors
2+
// This file is part of the go-ethereum library.
3+
//
4+
// The go-ethereum library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Lesser General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// The go-ethereum library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Lesser General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Lesser General Public License
15+
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
16+
17+
//go:build wasm
18+
// +build wasm
19+
20+
package rawdb
21+
22+
import (
23+
"errors"
24+
25+
"github.com/ethereum/go-ethereum/ethdb/memorydb"
26+
)
27+
28+
func isDbErrNotFound(err error) bool {
29+
return errors.Is(err, memorydb.ErrMemorydbNotFound)
30+
}

0 commit comments

Comments
 (0)