Skip to content

Commit 73b7f02

Browse files
committed
expose merkledb config defaults
Signed-off-by: Joshua Kim <[email protected]>
1 parent fbfc9aa commit 73b7f02

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

x/merkledb/db.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,21 @@ type MerkleDB interface {
159159
Prefetcher
160160
}
161161

162+
func NewConfig() Config {
163+
return Config{
164+
BranchFactor: BranchFactor16,
165+
Hasher: DefaultHasher,
166+
RootGenConcurrency: 0,
167+
HistoryLength: 300,
168+
ValueNodeCacheSize: units.MiB,
169+
IntermediateNodeCacheSize: units.MiB,
170+
IntermediateWriteBufferSize: units.KiB,
171+
IntermediateWriteBatchSize: 256 * units.KiB,
172+
TraceLevel: InfoTrace,
173+
Tracer: trace.Noop,
174+
}
175+
}
176+
162177
type Config struct {
163178
// BranchFactor determines the number of children each node can have.
164179
BranchFactor BranchFactor

x/merkledb/db_test.go

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"github.com/ava-labs/avalanchego/database/dbtest"
2222
"github.com/ava-labs/avalanchego/database/memdb"
2323
"github.com/ava-labs/avalanchego/ids"
24-
"github.com/ava-labs/avalanchego/trace"
2524
"github.com/ava-labs/avalanchego/utils/hashing"
2625
"github.com/ava-labs/avalanchego/utils/maybe"
2726
"github.com/ava-labs/avalanchego/utils/set"
@@ -40,19 +39,11 @@ func newDB(ctx context.Context, db database.Database, config Config) (*merkleDB,
4039
}
4140

4241
func newDefaultConfig() Config {
43-
return Config{
44-
BranchFactor: BranchFactor16,
45-
Hasher: DefaultHasher,
46-
RootGenConcurrency: 0,
47-
HistoryLength: defaultHistoryLength,
48-
ValueNodeCacheSize: units.MiB,
49-
IntermediateNodeCacheSize: units.MiB,
50-
IntermediateWriteBufferSize: units.KiB,
51-
IntermediateWriteBatchSize: 256 * units.KiB,
52-
Reg: prometheus.NewRegistry(),
53-
TraceLevel: InfoTrace,
54-
Tracer: trace.Noop,
55-
}
42+
config := NewConfig()
43+
config.HistoryLength = defaultHistoryLength
44+
config.Reg = prometheus.NewRegistry()
45+
46+
return config
5647
}
5748

5849
func Test_MerkleDB_Get_Safety(t *testing.T) {

x/merkledb/tracer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import "github.com/ava-labs/avalanchego/trace"
77

88
const (
99
DebugTrace TraceLevel = iota - 1
10-
InfoTrace // Default
10+
InfoTrace
1111
NoTrace
1212
)
1313

0 commit comments

Comments
 (0)