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

Problem: versiondb NewKVStore don't accept string as store name #1684

Merged
merged 3 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

* [#1679](https://github.com/crypto-org-chain/cronos/pull/1679) Include no trace detail on insufficient balance fix.

### Improvements

* [#]() versiondb NewKVStore accept string as store name.
yihuang marked this conversation as resolved.
Show resolved Hide resolved

*Nov 6, 2024*

## v1.4.0-rc3
Expand Down
5 changes: 3 additions & 2 deletions versiondb/go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module github.com/crypto-org-chain/cronos/versiondb

go 1.22
toolchain go1.22.9
go 1.22.7

toolchain go1.23.1

require (
cosmossdk.io/errors v1.0.1
Expand Down
4 changes: 2 additions & 2 deletions versiondb/multistore.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func NewMultiStore(
) *MultiStore {
stores := make(map[types.StoreKey]types.KVStore, len(storeKeys))
for _, k := range storeKeys {
stores[k] = NewKVStore(versionDB, k, nil)
stores[k] = NewKVStore(versionDB, k.Name(), nil)
}
return &MultiStore{
versionDB: versionDB,
Expand All @@ -61,7 +61,7 @@ func (s *MultiStore) cacheMultiStore(version *int64) types.CacheMultiStore {
if version == nil {
stores[k] = s.stores[k]
} else {
stores[k] = NewKVStore(s.versionDB, k, version)
stores[k] = NewKVStore(s.versionDB, k.Name(), version)
}
}
return cachemulti.NewStore(nil, stores, nil, s.traceWriter, s.getTracingContext())
Expand Down
16 changes: 8 additions & 8 deletions versiondb/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ var _ types.KVStore = (*Store)(nil)

// Store Implements types.KVStore
type Store struct {
store VersionStore
storeKey types.StoreKey
version *int64
store VersionStore
name string
version *int64
}

func NewKVStore(store VersionStore, storeKey types.StoreKey, version *int64) *Store {
func NewKVStore(store VersionStore, storeKey string, version *int64) *Store {
return &Store{store, storeKey, version}
}

Expand All @@ -38,7 +38,7 @@ func (st *Store) CacheWrap() types.CacheWrap {
// Implements types.KVStore.
func (st *Store) Get(key []byte) []byte {
defer telemetry.MeasureSince(time.Now(), "store", "versiondb", "get")
value, err := st.store.GetAtVersion(st.storeKey.Name(), key, st.version)
value, err := st.store.GetAtVersion(st.name, key, st.version)
if err != nil {
panic(err)
}
Expand All @@ -48,7 +48,7 @@ func (st *Store) Get(key []byte) []byte {
// Implements types.KVStore.
func (st *Store) Has(key []byte) (exists bool) {
defer telemetry.MeasureSince(time.Now(), "store", "versiondb", "has")
has, err := st.store.HasAtVersion(st.storeKey.Name(), key, st.version)
has, err := st.store.HasAtVersion(st.name, key, st.version)
if err != nil {
panic(err)
}
Expand All @@ -57,7 +57,7 @@ func (st *Store) Has(key []byte) (exists bool) {

// Implements types.KVStore.
func (st *Store) Iterator(start, end []byte) types.Iterator {
itr, err := st.store.IteratorAtVersion(st.storeKey.Name(), start, end, st.version)
itr, err := st.store.IteratorAtVersion(st.name, start, end, st.version)
if err != nil {
panic(err)
}
Expand All @@ -66,7 +66,7 @@ func (st *Store) Iterator(start, end []byte) types.Iterator {

// Implements types.KVStore.
func (st *Store) ReverseIterator(start, end []byte) types.Iterator {
itr, err := st.store.ReverseIteratorAtVersion(st.storeKey.Name(), start, end, st.version)
itr, err := st.store.ReverseIteratorAtVersion(st.name, start, end, st.version)
if err != nil {
panic(err)
}
Expand Down
Loading