Skip to content

Commit 8903163

Browse files
chore(docs): add documents of db (#888)
1 parent 9e713d0 commit 8903163

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Improvements
66

7+
- [#874](https://github.com/cosmos/iavl/pull/874) Decouple `cosmos-db` and implement own `db` package.
78
- [#695](https://github.com/cosmos/iavl/pull/695) Add API `SaveChangeSet` to save the changeset as a new version.
89
- [#703](https://github.com/cosmos/iavl/pull/703) New APIs `NewCompressExporter`/`NewCompressImporter` to support more compact snapshot format.
910
- [#729](https://github.com/cosmos/iavl/pull/729) Speedup Genesis writes for IAVL, by writing in small batches.

db/README.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# DB
2+
3+
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.
4+
5+
## Context
6+
7+
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:
8+
9+
```go
10+
package main
11+
12+
import (
13+
"cosmossdk.io/log"
14+
dbm "github.com/cosmos/cosmos-db"
15+
16+
"github.com/cosmos/iavl"
17+
idbm "github.com/cosmos/iavl/db"
18+
)
19+
20+
func main() {
21+
levelDB, err := dbm.NewDB("application", dbm.GoLevelDBBackend, "test")
22+
if err != nil {
23+
panic(err)
24+
}
25+
26+
tree := iavl.NewMutableTree(idbm.NewWrapper(dbm.NewPrefixDB(levelDB, []byte("s/k:main/"))), 0, false, log.NewNopLogger())
27+
}
28+
```

0 commit comments

Comments
 (0)