Skip to content

Commit

Permalink
add docs of db
Browse files Browse the repository at this point in the history
  • Loading branch information
cool-develope committed Feb 22, 2024
1 parent 9616f8e commit c1e3bdb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
28 changes: 28 additions & 0 deletions db/README.md
Original file line number Diff line number Diff line change
@@ -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())
}
```

0 comments on commit c1e3bdb

Please sign in to comment.