-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9616f8e
commit c1e3bdb
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | ||
} | ||
``` |