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

chore(docs): add documents of db #888

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The improvements listed in the Unreleased section of the CHANGELOG.md accurately reflect the significant changes made to the project, including the decoupling from cosmos-db, introduction of new APIs, and performance optimizations. However, it would be beneficial to include more context or details for each item to help users understand the impact of these changes better. For example:

  • For the decoupling of cosmos-db, briefly explain the benefits or reasons behind this move.
  • For new APIs like SaveChangeSet, NewCompressExporter, and NewCompressImporter, a short description of their use cases or advantages would be helpful.
  • The performance optimization for Genesis writes could include information on the expected improvements or how users can leverage this optimization.

Enhancing the descriptions in the CHANGELOG.md will provide users with a clearer understanding of the changes and how they can benefit from them.

- [#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())
}
```
Comment on lines +1 to +28
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README.md provides a clear overview of the db package, its purpose, and a practical example of how to use it. However, there are a few areas that could be improved for clarity and completeness:

  • It would be beneficial to include more details about the db package's capabilities beyond the memdb implementation, especially if there are other key-value stores supported or planned.
  • The example code is helpful, but adding comments within the code to explain each step would make it more accessible to newcomers.
  • A section on how to migrate from cosmos-db to the new db package could be valuable for users looking for a smooth transition.
  • Including information on performance considerations, limitations, or best practices when using the db package could provide users with a more comprehensive understanding.

Overall, the documentation is a good starting point but could be enhanced to offer more guidance and information to users.