Skip to content

Commit

Permalink
Problem: versiondb NewKVStore don't accept string as store name (#1684)
Browse files Browse the repository at this point in the history
* Problem: versiondb NewKVStore don't accept string as store name

* Update CHANGELOG.md

Signed-off-by: yihuang <[email protected]>

---------

Signed-off-by: yihuang <[email protected]>
  • Loading branch information
yihuang authored Nov 11, 2024
1 parent 2648b69 commit 9086913
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
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

* [#1684](https://github.com/crypto-org-chain/cronos/pull/1684) versiondb NewKVStore accept string as store name.

*Nov 6, 2024*

## v1.4.0-rc3
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

0 comments on commit 9086913

Please sign in to comment.