Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

iavl: *MutableTree doesn't provide a way to release the database; noticed inside iavl/cmd/iaviewer.ReadTree #618

Open
odeke-em opened this issue Nov 10, 2022 · 1 comment

Comments

@odeke-em
Copy link
Contributor

Noticed while I was working on some potential improvements for iavl/cmd/iaviewer that ReadTree whose code looks like this

iavl/cmd/iaviewer/main.go

Lines 120 to 136 in 172c349

func ReadTree(dir string, version int, prefix []byte) (*iavl.MutableTree, error) {
db, err := OpenDB(dir)
if err != nil {
return nil, err
}
if len(prefix) != 0 {
db = dbm.NewPrefixDB(db, prefix)
}
tree, err := iavl.NewMutableTree(db, DefaultCacheSize, false)
if err != nil {
return nil, err
}
ver, err := tree.LoadVersion(int64(version))
fmt.Printf("Got version: %d\n", ver)
return tree, err
}
returns *iavl.Mutable https://pkg.go.dev/github.com/cosmos/iavl#MutableTree which doesn't have a way to close the database, but this exhibits an API limitation that .MutableTree needs to return a way to close databases or better, perhaps ReadTree should just take in a database.

@tac0turtle
Copy link
Member

want to submit a pr?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants