Fixing store/* bugs...

This commit is contained in:
Jae Kwon 2017-12-04 00:23:10 -08:00
parent 0917fc3de7
commit 1d207a2a5e
5 changed files with 36 additions and 24 deletions

View File

@ -12,7 +12,6 @@ import (
"github.com/tendermint/tmlibs/log"
sdk "github.com/cosmos/cosmos-sdk"
"github.com/cosmos/cosmos-sdk/util"
)
const mainKeyHeader = "header"

View File

@ -1,5 +1,7 @@
package client
/*
import (
"path/filepath"
@ -25,3 +27,4 @@ func GetKeyManager(rootDir string) keys.Manager {
)
return manager
}
*/

7
glide.lock generated
View File

@ -128,9 +128,6 @@ imports:
subpackages:
- bcrypt
- keys
- keys/cryptostore
- keys/storage/filestorage
- keys/storage/memstorage
- keys/wordlist
- nano
- name: github.com/tendermint/go-wire
@ -139,7 +136,7 @@ imports:
- data
- data/base58
- name: github.com/tendermint/iavl
version: 595f3dcd5b6cd4a292e90757ae6d367fd7a6e653
version: 7198bc18ac0cf4ac0f57802d8022695640b79ec7
- name: github.com/tendermint/light-client
version: 76313d625e662ed7b284d066d68ff71edd7a9fac
subpackages:
@ -177,7 +174,7 @@ imports:
- types
- version
- name: github.com/tendermint/tmlibs
version: 0a652499ead7cd20a57a6a592f0491a2b493bb85
version: 17dc8a74497d3fee933592ef860275e6b0dd71d6
subpackages:
- autofile
- cli

View File

@ -8,18 +8,31 @@ import dbm "github.com/tendermint/tmlibs/db"
// cacheMultiStore holds many cache-wrapped stores.
// Implements MultiStore.
type cacheMultiStore struct {
db dbm.DB
version int64
db dbm.CacheDB
curVersion int64
lastCommitID CommitID
substores map[string]CacheWriter
}
func newCacheMultiStore(rs *rootMultiStore) cacheMultiStore {
func newCacheMultiStoreFromRMS(rms *rootMultiStore) cacheMultiStore {
cms := cacheMultiStore{
db: rs.db.CacheDB(),
version: rs.curVersion,
lastCommitID: rs.lastCommitID,
substores: make(map[string]CacheWriter, len(rs.substores)),
db: rms.db.CacheDB(),
curVersion: rms.curVersion,
lastCommitID: rms.lastCommitID,
substores: make(map[string]CacheWriter, len(rms.substores)),
}
for name, substore := range rms.substores {
cms.substores[name] = substore.CacheWrap().(CacheWriter)
}
return cms
}
func newCacheMultiStoreFromCMS(cms cacheMultiStore) cacheMultiStore {
cms := cacheMultiStore{
db: cms.db.CacheDB(),
curVersion: cms.curVersion,
lastCommitID: cms.lastCommitID,
substores: make(map[string]CacheWriter, len(cms.substores)),
}
for name, substore := range rs.substores {
cms.substores[name] = substore.CacheWrap().(CacheWriter)
@ -34,33 +47,33 @@ func (cms cacheMultiStore) LastCommitID() CommitID {
// Implements CacheMultiStore
func (cms cacheMultiStore) CurrentVersion() int64 {
return cms.version
return cms.curVersion
}
// Implements CacheMultiStore
func (cms cacheMultiStore) Write() {
cms.db.Write()
for substore := range cms.substores {
for _, substore := range cms.substores {
substore.Write()
}
}
// Implements CacheMultiStore
func (rs cacheMultiStore) CacheMultiStore() CacheMultiStore {
return newCacheMultiStore(rs)
func (cms cacheMultiStore) CacheMultiStore() CacheMultiStore {
return newCacheMultiStoreFromCMS(cms)
}
// Implements CacheMultiStore
func (rs cacheMultiStore) GetCommitter(name string) Committer {
return rs.store[name]
func (cms cacheMultiStore) GetCommitter(name string) Committer {
return cms.store[name]
}
// Implements CacheMultiStore
func (rs cacheMultiStore) GetKVStore(name string) KVStore {
return rs.store[name].(KVStore)
func (cms cacheMultiStore) GetKVStore(name string) KVStore {
return cms.store[name].(KVStore)
}
// Implements CacheMultiStore
func (rs cacheMultiStore) GetIterKVStore(name string) IterKVStore {
return rs.store[name].(IterKVStore)
func (cms cacheMultiStore) GetIterKVStore(name string) IterKVStore {
return cms.store[name].(IterKVStore)
}

View File

@ -174,7 +174,7 @@ func (rs *rootMultiStore) LastCommitID() CommitID {
// Implements MultiStore
func (rs *rootMultiStore) CacheMultiStore() CacheMultiStore {
return newCacheMultiStore(rs)
return newCacheMultiStoreFromRMS(rs)
}
// Implements MultiStore