Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

refactor: add logger #735

Merged
merged 5 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"sort"
"testing"

"cosmossdk.io/log"
db "github.com/cosmos/cosmos-db"
iavlrand "github.com/cosmos/iavl/internal/rand"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -445,15 +446,15 @@ func TestPersistence(t *testing.T) {
}

// Construct some tree and save it
t1, err := NewMutableTree(db, 0, false)
t1, err := NewMutableTree(db, 0, false, log.NewNopLogger())
require.NoError(t, err)
for key, value := range records {
t1.Set([]byte(key), []byte(value))
}
t1.SaveVersion()

// Load a tree
t2, err := NewMutableTree(db, 0, false)
t2, err := NewMutableTree(db, 0, false, log.NewNopLogger())
require.NoError(t, err)
t2.Load()
for key, value := range records {
Expand Down Expand Up @@ -503,7 +504,7 @@ func TestProof(t *testing.T) {

func TestTreeProof(t *testing.T) {
db := db.NewMemDB()
tree, err := NewMutableTree(db, 100, false)
tree, err := NewMutableTree(db, 100, false, log.NewNopLogger())
require.NoError(t, err)
hash, err := tree.Hash()
require.NoError(t, err)
Expand Down
3 changes: 2 additions & 1 deletion benchmarks/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strings"
"testing"

"cosmossdk.io/log"
"github.com/stretchr/testify/require"

db "github.com/cosmos/cosmos-db"
Expand All @@ -25,7 +26,7 @@ func randBytes(length int) []byte {
}

func prepareTree(b *testing.B, db db.DB, size, keyLen, dataLen int) (*iavl.MutableTree, [][]byte) {
t, err := iavl.NewMutableTreeWithOpts(db, size, nil, false)
t, err := iavl.NewMutableTreeWithOpts(db, size, nil, false, log.NewNopLogger())
require.NoError(b, err)
keys := make([][]byte, size)

Expand Down
7 changes: 4 additions & 3 deletions benchmarks/cosmos-exim/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"time"

"cosmossdk.io/log"
tmdb "github.com/cosmos/cosmos-db"
"github.com/cosmos/iavl"
)
Expand Down Expand Up @@ -90,7 +91,7 @@ func runExport(dbPath string) (int64, map[string][]*iavl.ExportNode, error) {
if err != nil {
return 0, nil, err
}
tree, err := iavl.NewMutableTree(tmdb.NewPrefixDB(ldb, []byte("s/k:main/")), 0, false)
tree, err := iavl.NewMutableTree(tmdb.NewPrefixDB(ldb, []byte("s/k:main/")), 0, false, log.NewNopLogger())
if err != nil {
return 0, nil, err
}
Expand All @@ -105,7 +106,7 @@ func runExport(dbPath string) (int64, map[string][]*iavl.ExportNode, error) {
totalStats := Stats{}
for _, name := range stores {
db := tmdb.NewPrefixDB(ldb, []byte("s/k:"+name+"/"))
tree, err := iavl.NewMutableTree(db, 0, false)
tree, err := iavl.NewMutableTree(db, 0, false, log.NewNopLogger())
if err != nil {
return 0, nil, err
}
Expand Down Expand Up @@ -173,7 +174,7 @@ func runImport(version int64, exports map[string][]*iavl.ExportNode) error {
if err != nil {
return err
}
newTree, err := iavl.NewMutableTree(newDB, 0, false)
newTree, err := iavl.NewMutableTree(newDB, 0, false, log.NewNopLogger())
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/iaviewer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strconv"
"strings"

"cosmossdk.io/log"
dbm "github.com/cosmos/cosmos-db"

"github.com/cosmos/iavl"
Expand Down Expand Up @@ -126,7 +127,7 @@ func ReadTree(dir string, version int, prefix []byte) (*iavl.MutableTree, error)
db = dbm.NewPrefixDB(db, prefix)
}

tree, err := iavl.NewMutableTree(db, DefaultCacheSize, false)
tree, err := iavl.NewMutableTree(db, DefaultCacheSize, false, log.NewNopLogger())
tac0turtle marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return nil, err
}
Expand Down
5 changes: 3 additions & 2 deletions diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"sort"
"testing"

"cosmossdk.io/log"
db "github.com/cosmos/cosmos-db"
"github.com/stretchr/testify/require"
)
Expand All @@ -19,7 +20,7 @@ func TestDiffRoundTrip(t *testing.T) {

// apply changeSets to tree
db := db.NewMemDB()
tree, err := NewMutableTree(db, 0, true)
tree, err := NewMutableTree(db, 0, true, log.NewNopLogger())
require.NoError(t, err)
for i := range changeSets {
v, err := tree.SaveChangeSet(changeSets[i])
Expand All @@ -29,7 +30,7 @@ func TestDiffRoundTrip(t *testing.T) {

// extract change sets from db
var extractChangeSets []*ChangeSet
tree2 := NewImmutableTree(db, 0, true)
tree2 := NewImmutableTree(db, 0, true, log.NewNopLogger())
err = tree2.TraverseStateChanges(0, math.MaxInt64, func(version int64, changeSet *ChangeSet) error {
extractChangeSets = append(extractChangeSets, changeSet)
return nil
Expand Down
13 changes: 7 additions & 6 deletions export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"math/rand"
"testing"

"cosmossdk.io/log"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand All @@ -14,7 +15,7 @@ import (
// setupExportTreeBasic sets up a basic tree with a handful of
// create/update/delete operations over a few versions.
func setupExportTreeBasic(t require.TestingT) *ImmutableTree {
tree, err := NewMutableTree(db.NewMemDB(), 0, false)
tree, err := NewMutableTree(db.NewMemDB(), 0, false, log.NewNopLogger())
require.NoError(t, err)

_, err = tree.Set([]byte("x"), []byte{255})
Expand Down Expand Up @@ -74,7 +75,7 @@ func setupExportTreeRandom(t *testing.T) *ImmutableTree {
)

r := rand.New(rand.NewSource(randSeed))
tree, err := NewMutableTree(db.NewMemDB(), 0, false)
tree, err := NewMutableTree(db.NewMemDB(), 0, false, log.NewNopLogger())
require.NoError(t, err)

var version int64
Expand Down Expand Up @@ -134,7 +135,7 @@ func setupExportTreeSized(t require.TestingT, treeSize int) *ImmutableTree { //n
)

r := rand.New(rand.NewSource(randSeed))
tree, err := NewMutableTree(db.NewMemDB(), 0, false)
tree, err := NewMutableTree(db.NewMemDB(), 0, false, log.NewNopLogger())
require.NoError(t, err)

for i := 0; i < treeSize; i++ {
Expand Down Expand Up @@ -229,7 +230,7 @@ func TestExporterCompress(t *testing.T) {

func TestExporter_Import(t *testing.T) {
testcases := map[string]*ImmutableTree{
"empty tree": NewImmutableTree(db.NewMemDB(), 0, false),
"empty tree": NewImmutableTree(db.NewMemDB(), 0, false, log.NewNopLogger()),
"basic tree": setupExportTreeBasic(t),
}
if !testing.Short() {
Expand All @@ -256,7 +257,7 @@ func TestExporter_Import(t *testing.T) {
exporter = NewCompressExporter(innerExporter)
}

newTree, err := NewMutableTree(db.NewMemDB(), 0, false)
newTree, err := NewMutableTree(db.NewMemDB(), 0, false, log.NewNopLogger())
require.NoError(t, err)
innerImporter, err := newTree.Import(tree.Version())
require.NoError(t, err)
Expand Down Expand Up @@ -327,7 +328,7 @@ func TestExporter_Close(t *testing.T) {
}

func TestExporter_DeleteVersionErrors(t *testing.T) {
tree, err := NewMutableTree(db.NewMemDB(), 0, false)
tree, err := NewMutableTree(db.NewMemDB(), 0, false, log.NewNopLogger())
require.NoError(t, err)

_, err = tree.Set([]byte("a"), []byte{1})
Expand Down
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ module github.com/cosmos/iavl
go 1.18

require (
cosmossdk.io/log v1.0.0
github.com/cosmos/cosmos-db v1.0.0-rc.1
github.com/cosmos/ics23/go v0.9.1-0.20221207100636-b1abd8678aab
github.com/emicklei/dot v1.4.2
github.com/golang/mock v1.6.0
github.com/golangci/golangci-lint v1.52.2
github.com/stretchr/testify v1.8.2
golang.org/x/crypto v0.8.0
google.golang.org/protobuf v1.28.1
)

require (
Expand Down Expand Up @@ -116,7 +118,7 @@ require (
github.com/maratori/testpackage v1.1.1 // indirect
github.com/matoous/godox v0.0.0-20230222163458-006bad1f9d26 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mbilski/exhaustivestruct v1.2.0 // indirect
Expand Down Expand Up @@ -144,6 +146,7 @@ require (
github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/rs/zerolog v1.29.0 // indirect
github.com/ryancurrah/gomodguard v1.3.0 // indirect
github.com/ryanrolds/sqlclosecheck v0.4.0 // indirect
github.com/sanposhiho/wastedassign/v2 v2.0.7 // indirect
Expand Down Expand Up @@ -192,7 +195,6 @@ require (
golang.org/x/text v0.9.0 // indirect
golang.org/x/tools v0.7.0 // indirect
gonum.org/v1/gonum v0.11.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
17 changes: 15 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
cosmossdk.io/log v1.0.0 h1:NGKZ/A5rd4PduDfoscgABklX557PWjQINbosZy/m3Jk=
cosmossdk.io/log v1.0.0/go.mod h1:CwX9BLiBruZb7lzLlRr3R231d/fVPUXk8gAdV4LQap0=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/Abirdcfly/dupword v0.0.11 h1:z6v8rMETchZXUIuHxYNmlUAuKuB21PeaSymTed16wgU=
github.com/Abirdcfly/dupword v0.0.11/go.mod h1:wH8mVGuf3CP5fsBTkfWwwwKTjDnVVCxtU8d8rgeVYXA=
Expand Down Expand Up @@ -133,6 +135,7 @@ github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcju
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cosmos/cosmos-db v1.0.0-rc.1 h1:SjnT8B6WKMW9WEIX32qMhnEEKcI7ZP0+G1Sa9HD3nmY=
github.com/cosmos/cosmos-db v1.0.0-rc.1/go.mod h1:Dnmk3flSf5lkwCqvvjNpoxjpXzhxnCAFzKHlbaForso=
github.com/cosmos/gogoproto v1.4.3 h1:RP3yyVREh9snv/lsOvmsAPQt8f44LgL281X0IOIhhcI=
Expand Down Expand Up @@ -233,6 +236,7 @@ github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJA
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw=
github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
github.com/gogo/googleapis v0.0.0-20180223154316-0cd9801be74a/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
Expand Down Expand Up @@ -462,14 +466,16 @@ github.com/matoous/godox v0.0.0-20230222163458-006bad1f9d26/go.mod h1:1BELzlh859
github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE=
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98=
github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw=
Expand Down Expand Up @@ -584,6 +590,9 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w=
github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryancurrah/gomodguard v1.3.0 h1:q15RT/pd6UggBXVBuLps8BXRvl5GPBcwVA7BJHMLuTw=
Expand Down Expand Up @@ -928,7 +937,9 @@ golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210909193231-528a39cd75f3/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211105183446-c75c47738b0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand All @@ -944,6 +955,7 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
Expand Down Expand Up @@ -1179,6 +1191,7 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
17 changes: 9 additions & 8 deletions immutable_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"strings"

"cosmossdk.io/log"
dbm "github.com/cosmos/cosmos-db"
)

Expand All @@ -14,30 +15,30 @@ import (
// Returned key/value byte slices must not be modified, since they may point to data located inside
// IAVL which would also be modified.
type ImmutableTree struct {
logger log.Logger

root *Node
ndb *nodeDB
version int64
skipFastStorageUpgrade bool
}

// NewImmutableTree creates both in-memory and persistent instances
func NewImmutableTree(db dbm.DB, cacheSize int, skipFastStorageUpgrade bool) *ImmutableTree {
func NewImmutableTree(db dbm.DB, cacheSize int, skipFastStorageUpgrade bool, lg log.Logger) *ImmutableTree {
if db == nil {
// In-memory Tree.
return &ImmutableTree{}
}
return &ImmutableTree{
// NodeDB-backed Tree.
ndb: newNodeDB(db, cacheSize, nil),
skipFastStorageUpgrade: skipFastStorageUpgrade,
}

return NewImmutableTreeWithOpts(db, cacheSize, nil, skipFastStorageUpgrade, lg)
}

// NewImmutableTreeWithOpts creates an ImmutableTree with the given options.
func NewImmutableTreeWithOpts(db dbm.DB, cacheSize int, opts *Options, skipFastStorageUpgrade bool) *ImmutableTree {
func NewImmutableTreeWithOpts(db dbm.DB, cacheSize int, opts *Options, skipFastStorageUpgrade bool, lg log.Logger) *ImmutableTree {
return &ImmutableTree{
logger: lg,
// NodeDB-backed Tree.
ndb: newNodeDB(db, cacheSize, opts),
ndb: newNodeDB(db, cacheSize, opts, lg),
skipFastStorageUpgrade: skipFastStorageUpgrade,
}
}
Expand Down
Loading