Skip to content

Commit cbd8271

Browse files
committed
fix: reduce diff in journal.go
1 parent 98a81dc commit cbd8271

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

graft/coreth/core/state/snapshot/journal.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,6 @@ import (
4242
"github.com/ava-labs/libevm/triedb"
4343
)
4444

45-
var (
46-
errSnapshotRootEmpty = errors.New("missing or corrupted snapshot, no snapshot root")
47-
errSnapshotBlockHashEmpty = errors.New("missing or corrupted snapshot, no snapshot block hash")
48-
errSnapshotRootMismatch = errors.New("snapshot root mismatch")
49-
errSnapshotGeneratorMissing = errors.New("missing snapshot generator")
50-
)
51-
5245
// journalGenerator is a disk layer entry containing the generator progress marker.
5346
type journalGenerator struct {
5447
// Indicator that whether the database was in progress of being wiped.
@@ -69,24 +62,24 @@ func loadSnapshot(diskdb ethdb.KeyValueStore, triedb *triedb.Database, cache int
6962
// Retrieve the block hash of the snapshot, failing if no snapshot is present.
7063
baseBlockHash, err := customrawdb.ReadSnapshotBlockHash(diskdb)
7164
if err != nil {
72-
return nil, false, errSnapshotBlockHashEmpty
65+
return nil, false, errors.New("missing or corrupted snapshot, no snapshot block hash")
7366
}
7467

7568
// Retrieve and validate the snapshot root.
7669
baseRoot := rawdb.ReadSnapshotRoot(diskdb)
7770
switch {
7871
case baseRoot == (common.Hash{}):
79-
return nil, false, errSnapshotRootEmpty
72+
return nil, false, errors.New("missing or corrupted snapshot, no snapshot root")
8073
case baseRoot != root:
81-
return nil, false, fmt.Errorf("%w: stored %#x, expected %#x", errSnapshotRootMismatch, baseRoot, root)
74+
return nil, false, fmt.Errorf("root stored on disk (%#x) does not match last accepted (%#x)", baseRoot, root)
8275
}
8376

8477
// Retrieve the disk layer generator. It must exist, no matter the
8578
// snapshot is fully generated or not. Otherwise the entire disk
8679
// layer is invalid.
8780
generatorBlob := rawdb.ReadSnapshotGenerator(diskdb)
8881
if len(generatorBlob) == 0 {
89-
return nil, false, errSnapshotGeneratorMissing
82+
return nil, false, errors.New("missing snapshot generator")
9083
}
9184
var generator journalGenerator
9285
if err := rlp.DecodeBytes(generatorBlob, &generator); err != nil {

0 commit comments

Comments
 (0)