diff --git a/CHANGELOG.md b/CHANGELOG.md index 46ef0ec8f..f68c6b816 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Improvements +- [#874](https://github.com/cosmos/iavl/pull/874) Decouple `cosmos-db` and implement own `db` package. - [#695](https://github.com/cosmos/iavl/pull/695) Add API `SaveChangeSet` to save the changeset as a new version. - [#703](https://github.com/cosmos/iavl/pull/703) New APIs `NewCompressExporter`/`NewCompressImporter` to support more compact snapshot format. - [#729](https://github.com/cosmos/iavl/pull/729) Speedup Genesis writes for IAVL, by writing in small batches. diff --git a/db/README.md b/db/README.md new file mode 100644 index 000000000..b2885e328 --- /dev/null +++ b/db/README.md @@ -0,0 +1,28 @@ +# DB + +The `db` package contains the key-value database interface and `memdb` implementation. The `memdb` is a simple in-memory key-value store that is used for testing and development purposes. + +## Context + +The main purpose of the `db` package is to provide decoupling between `cosmos-db` and `iavl` packages. It provides a simple `wrapper` for the old users of `iavl` and `cosmos-db` to use the new `db` package without changing their code. For example: + +```go +package main + +import ( + "cosmossdk.io/log" + dbm "github.com/cosmos/cosmos-db" + + "github.com/cosmos/iavl" + idbm "github.com/cosmos/iavl/db" +) + +func main() { + levelDB, err := dbm.NewDB("application", dbm.GoLevelDBBackend, "test") + if err != nil { + panic(err) + } + + tree := iavl.NewMutableTree(idbm.NewWrapper(dbm.NewPrefixDB(levelDB, []byte("s/k:main/"))), 0, false, log.NewNopLogger()) +} +```