Skip to content

Commit

Permalink
revert unnecessary change
Browse files Browse the repository at this point in the history
  • Loading branch information
GAtom22 committed Aug 8, 2024
1 parent f74ae7d commit e0f169e
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 66 deletions.
4 changes: 0 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
* (client) [#19870](https://github.com/cosmos/cosmos-sdk/pull/19870) Add new query command `wait-tx`. Alias `event-query-tx-for` to `wait-tx` for backward compatibility.
* (crypto/keyring) [#20212](https://github.com/cosmos/cosmos-sdk/pull/20212) Expose the db keyring used in the keystore.
* (genutil) [#19971](https://github.com/cosmos/cosmos-sdk/pull/19971) Allow manually setting the consensus key type in genesis
<<<<<<< HEAD
* (store) [#20862](https://github.com/cosmos/cosmos-sdk/pull/20862) Add `Copy()` method for `CacheMultiStore` and `cachekv.Store`.
=======
* (client/tx) [#20870](https://github.com/cosmos/cosmos-sdk/pull/20870) Add `timeout-timestamp` field for tx body defines time based timeout.Add `WithTimeoutTimestamp` to tx factory. Increased gas cost for processing newly added timeout timestamp field in tx body.
>>>>>>> upstream/main

### Improvements

Expand Down
32 changes: 0 additions & 32 deletions store/cachekv/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,38 +161,6 @@ func (store *Store) Write() {
}
}

// Copy creates a deep copy of the Store object
func (store *Store) Copy() types.CacheKVStore {
store.mtx.Lock()
defer store.mtx.Unlock()

// Copy cache
cacheCopy := make(map[string]*cValue, len(store.cache))
for key, val := range store.cache {
newVal := *val // Create a copy of the cValue
cacheCopy[key] = &newVal
}

// Copy unsortedCache
unsortedCacheCopy := make(map[string]struct{}, len(store.unsortedCache))
for key := range store.unsortedCache {
unsortedCacheCopy[key] = struct{}{}
}

// Copy sortedCache
sortedCacheCopy := store.sortedCache.Copy()

// Create new Store with copied values
newStore := &Store{
cache: cacheCopy,
unsortedCache: unsortedCacheCopy,
sortedCache: sortedCacheCopy,
parent: store.parent,
}

return newStore
}

// CacheWrap implements CacheWrapper.
func (store *Store) CacheWrap() types.CacheWrap {
return NewStore(store)
Expand Down
26 changes: 0 additions & 26 deletions store/cachemulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,32 +127,6 @@ func (cms Store) Write() {
}
}

// Copy creates a deep copy of the Store object
func (cms Store) Copy() types.CacheMultiStore {
// Deep copy the db field
newDB := cms.db.Copy()

// Deep copy the cachekv stores map
newStores := make(map[types.StoreKey]types.CacheWrap, len(cms.stores))
for key, store := range cms.stores {
store, ok := store.(*cachekv.Store)
if ok {
newStores[key] = store.Copy()
}
}

// Create new Store with copied values
newStore := Store{
db: newDB,
stores: newStores,
keys: cms.keys,
traceWriter: cms.traceWriter,
traceContext: cms.traceContext,
}

return newStore
}

// Implements CacheWrapper.
func (cms Store) CacheWrap() types.CacheWrap {
return cms.CacheMultiStore().(types.CacheWrap)
Expand Down
5 changes: 1 addition & 4 deletions store/types/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ type MultiStore interface {
// CacheMultiStore is from MultiStore.CacheMultiStore()....
type CacheMultiStore interface {
MultiStore
Write() // Writes operations to underlying KVStore
Copy() CacheMultiStore // Returns a deep copy of the CacheMultiStore
Write() // Writes operations to underlying KVStore
}

// CommitMultiStore is an interface for a MultiStore without cache capabilities.
Expand Down Expand Up @@ -287,8 +286,6 @@ type CacheKVStore interface {

// Write writes operations to underlying KVStore
Write()
// Copy creates a deep copy of the Store object
Copy() CacheKVStore
}

// CommitKVStore is an interface for MultiStore.
Expand Down

0 comments on commit e0f169e

Please sign in to comment.