@@ -15,6 +15,8 @@ import (
15
15
// MultiTree encapsulates multiple IAVL trees, each with its own "store key" in the context of the Cosmos SDK.
16
16
// Within IAVL v2 is only used to test the IAVL v2 implementation, and for import/export of IAVL v2 state.
17
17
type MultiTree struct {
18
+ logger Logger
19
+
18
20
Trees map [string ]* Tree
19
21
20
22
pool * NodePool
@@ -26,7 +28,7 @@ type MultiTree struct {
26
28
errorCh chan error
27
29
}
28
30
29
- func NewMultiTree (rootPath string , opts TreeOptions ) * MultiTree {
31
+ func NewMultiTree (logger Logger , rootPath string , opts TreeOptions ) * MultiTree {
30
32
return & MultiTree {
31
33
Trees : make (map [string ]* Tree ),
32
34
doneCh : make (chan saveVersionResult , 1000 ),
@@ -37,8 +39,8 @@ func NewMultiTree(rootPath string, opts TreeOptions) *MultiTree {
37
39
}
38
40
}
39
41
40
- func ImportMultiTree (pool * NodePool , version int64 , path string , treeOpts TreeOptions ) (* MultiTree , error ) {
41
- mt := NewMultiTree (path , treeOpts )
42
+ func ImportMultiTree (logger Logger , pool * NodePool , version int64 , path string , treeOpts TreeOptions ) (* MultiTree , error ) {
43
+ mt := NewMultiTree (logger , path , treeOpts )
42
44
paths , err := FindDbsInPath (path )
43
45
if err != nil {
44
46
return nil , err
@@ -78,7 +80,7 @@ func ImportMultiTree(pool *NodePool, version int64, path string, treeOpts TreeOp
78
80
return nil , err
79
81
case res := <- done :
80
82
prefix := filepath .Base (res .path )
81
- log .Info (). Msgf ("imported %s" , prefix )
83
+ logger .Info (fmt . Sprintf ("imported %s" , prefix ) )
82
84
mt .Trees [prefix ] = res .tree
83
85
}
84
86
}
@@ -108,7 +110,6 @@ func (mt *MultiTree) MountTrees() error {
108
110
prefix := filepath .Base (dbPath )
109
111
sqlOpts := defaultSqliteDbOptions (SqliteDbOptions {})
110
112
sqlOpts .Path = dbPath
111
- log .Info ().Msgf ("mounting %s; opts %v" , prefix , sqlOpts )
112
113
sql , err := NewSqliteDb (mt .pool , sqlOpts )
113
114
if err != nil {
114
115
return err
@@ -173,7 +174,7 @@ func (mt *MultiTree) SaveVersionConcurrently() ([]byte, int64, error) {
173
174
for i := 0 ; i < treeCount ; i ++ {
174
175
select {
175
176
case err := <- mt .errorCh :
176
- log . Error (). Err ( err ). Msg ( "failed to save version" )
177
+ mt . logger . Error ("failed to save version" , "error" , err )
177
178
errs = append (errs , err )
178
179
case result := <- mt .doneCh :
179
180
if version != - 1 && version != result .version {
@@ -218,7 +219,7 @@ func (mt *MultiTree) SnapshotConcurrently() error {
218
219
for i := 0 ; i < treeCount ; i ++ {
219
220
select {
220
221
case err := <- mt .errorCh :
221
- log . Error (). Err ( err ). Msg ( "failed to snapshot" )
222
+ mt . logger . Error ("failed to snapshot" , "error" , err )
222
223
errs = append (errs , err )
223
224
case <- mt .doneCh :
224
225
}
@@ -271,7 +272,7 @@ func (mt *MultiTree) WarmLeaves() error {
271
272
for i := 0 ; i < cnt ; i ++ {
272
273
select {
273
274
case err := <- mt .errorCh :
274
- log . Error (). Err ( err ). Msg ( "failed to warm leaves" )
275
+ mt . logger . Error ("failed to warm leaves" , "error" , err )
275
276
return err
276
277
case <- mt .doneCh :
277
278
}
0 commit comments