Skip to content

Commit 225d960

Browse files
committed
use enum
1 parent 26098c7 commit 225d960

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

core/trie2/triedb/database/db.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ import (
99
"github.com/NethermindEth/juno/db"
1010
)
1111

12+
type TrieDBScheme uint8
13+
14+
const (
15+
RawScheme TrieDBScheme = iota + 1
16+
PathScheme
17+
HashScheme
18+
)
19+
1220
// Represents a reader for trie nodes
1321
type NodeReader interface {
1422
Node(owner *felt.Felt, path *trieutils.Path, hash *felt.Felt, isLeaf bool) ([]byte, error)
@@ -37,5 +45,5 @@ type TrieDB interface {
3745
mergeClassNodes,
3846
mergeContractNodes *trienode.MergeNodeSet,
3947
) error
40-
Scheme() string
48+
Scheme() TrieDBScheme
4149
}

core/trie2/triedb/hashdb/database.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import (
1313
"github.com/NethermindEth/juno/utils"
1414
)
1515

16-
const HashScheme string = "hash"
17-
1816
var _ database.TrieDB = (*Database)(nil)
1917

2018
type Config struct {
@@ -259,6 +257,6 @@ func (d *Database) GetTrieRootNodes(classRootHash, contractRootHash *felt.Felt)
259257
return classRootNode, contractRootNode, nil
260258
}
261259

262-
func (d *Database) Scheme() string {
263-
return HashScheme
260+
func (d *Database) Scheme() database.TrieDBScheme {
261+
return database.HashScheme
264262
}

core/trie2/triedb/pathdb/database.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ import (
1212
)
1313

1414
const (
15-
maxDiffLayers = 128 // TODO(weiihann): might want to make this configurable
16-
contractClassTrieHeight = 251
17-
PathScheme string = "path"
15+
maxDiffLayers = 128 // TODO(weiihann): might want to make this configurable
16+
contractClassTrieHeight = 251
1817
)
1918

2019
var _ database.TrieDB = (*Database)(nil)
@@ -107,6 +106,6 @@ func (d *Database) NewIterator(id trieutils.TrieID) (db.Iterator, error) {
107106
return d.disk.NewIterator(prefix, true)
108107
}
109108

110-
func (d *Database) Scheme() string {
111-
return PathScheme
109+
func (d *Database) Scheme() database.TrieDBScheme {
110+
return database.PathScheme
112111
}

core/trie2/triedb/rawdb/database.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import (
1111
"github.com/NethermindEth/juno/utils"
1212
)
1313

14-
const RawScheme string = "raw"
15-
1614
var _ database.TrieDB = (*Database)(nil)
1715

1816
type Config struct{}
@@ -137,6 +135,6 @@ func (d *Database) Close() error {
137135
return nil
138136
}
139137

140-
func (d *Database) Scheme() string {
141-
return RawScheme
138+
func (d *Database) Scheme() database.TrieDBScheme {
139+
return database.RawScheme
142140
}

0 commit comments

Comments
 (0)