curVersion -> nextVersion
This commit is contained in:
@@ -7,7 +7,7 @@ package store
|
||||
// Implements MultiStore.
|
||||
type cacheMultiStore struct {
|
||||
db CacheKVStore
|
||||
curVersion int64
|
||||
nextVersion int64
|
||||
lastCommitID CommitID
|
||||
substores map[string]CacheWrap
|
||||
}
|
||||
@@ -15,7 +15,7 @@ type cacheMultiStore struct {
|
||||
func newCacheMultiStoreFromRMS(rms *rootMultiStore) cacheMultiStore {
|
||||
cms := cacheMultiStore{
|
||||
db: NewCacheKVStore(rms.db),
|
||||
curVersion: rms.curVersion,
|
||||
nextVersion: rms.nextVersion,
|
||||
lastCommitID: rms.lastCommitID,
|
||||
substores: make(map[string]CacheWrap, len(rms.substores)),
|
||||
}
|
||||
@@ -28,7 +28,7 @@ func newCacheMultiStoreFromRMS(rms *rootMultiStore) cacheMultiStore {
|
||||
func newCacheMultiStoreFromCMS(cms cacheMultiStore) cacheMultiStore {
|
||||
cms2 := cacheMultiStore{
|
||||
db: NewCacheKVStore(cms.db),
|
||||
curVersion: cms.curVersion,
|
||||
nextVersion: cms.nextVersion,
|
||||
lastCommitID: cms.lastCommitID,
|
||||
substores: make(map[string]CacheWrap, len(cms.substores)),
|
||||
}
|
||||
@@ -44,8 +44,8 @@ func (cms cacheMultiStore) LastCommitID() CommitID {
|
||||
}
|
||||
|
||||
// Implements CacheMultiStore
|
||||
func (cms cacheMultiStore) CurrentVersion() int64 {
|
||||
return cms.curVersion
|
||||
func (cms cacheMultiStore) NextVersion() int64 {
|
||||
return cms.nextVersion
|
||||
}
|
||||
|
||||
// Implements CacheMultiStore
|
||||
|
||||
@@ -20,7 +20,7 @@ const (
|
||||
// Implements MultiStore.
|
||||
type rootMultiStore struct {
|
||||
db dbm.DB
|
||||
curVersion int64
|
||||
nextVersion int64
|
||||
lastCommitID CommitID
|
||||
storeLoaders map[string]CommitStoreLoader
|
||||
substores map[string]CommitStore
|
||||
@@ -29,7 +29,7 @@ type rootMultiStore struct {
|
||||
func NewMultiStore(db dbm.DB) *rootMultiStore {
|
||||
return &rootMultiStore{
|
||||
db: db,
|
||||
curVersion: 0,
|
||||
nextVersion: 0,
|
||||
storeLoaders: make(map[string]CommitStoreLoader),
|
||||
substores: make(map[string]CommitStore),
|
||||
}
|
||||
@@ -49,8 +49,8 @@ func (rs *rootMultiStore) LoadLatestVersion() error {
|
||||
}
|
||||
|
||||
// NOTE: Returns 0 unless LoadVersion() or LoadLatestVersion() is called.
|
||||
func (rs *rootMultiStore) GetCurrentVersion() int64 {
|
||||
return rs.curVersion
|
||||
func (rs *rootMultiStore) NextVersion() int64 {
|
||||
return rs.nextVersion
|
||||
}
|
||||
|
||||
func (rs *rootMultiStore) LoadVersion(ver int64) error {
|
||||
@@ -65,7 +65,7 @@ func (rs *rootMultiStore) LoadVersion(ver int64) error {
|
||||
rs.substores[name] = store
|
||||
}
|
||||
|
||||
rs.curVersion = 1
|
||||
rs.nextVersion = 1
|
||||
rs.lastCommitID = CommitID{}
|
||||
return nil
|
||||
}
|
||||
@@ -100,7 +100,7 @@ func (rs *rootMultiStore) LoadVersion(ver int64) error {
|
||||
}
|
||||
|
||||
// Success.
|
||||
rs.curVersion = ver + 1
|
||||
rs.nextVersion = ver + 1
|
||||
rs.lastCommitID = state.CommitID()
|
||||
rs.substores = newSubstores
|
||||
return nil
|
||||
@@ -110,7 +110,7 @@ func (rs *rootMultiStore) LoadVersion(ver int64) error {
|
||||
func (rs *rootMultiStore) Commit() CommitID {
|
||||
|
||||
// Commit substores
|
||||
version := rs.curVersion
|
||||
version := rs.nextVersion
|
||||
state := commitSubstores(version, rs.substores)
|
||||
|
||||
// Need to update self state atomically.
|
||||
@@ -120,7 +120,7 @@ func (rs *rootMultiStore) Commit() CommitID {
|
||||
batch.Write()
|
||||
|
||||
// Prepare for next version.
|
||||
rs.curVersion = version + 1
|
||||
rs.nextVersion = version + 1
|
||||
commitID := CommitID{
|
||||
Version: version,
|
||||
Hash: state.Hash(),
|
||||
|
||||
@@ -77,7 +77,7 @@ func newMultiStoreWithLoaders(db dbm.DB) *rootMultiStore {
|
||||
}
|
||||
|
||||
func checkStore(t *testing.T, store *rootMultiStore, expect, got CommitID) {
|
||||
assert.EqualValues(t, expect.Version+1, store.GetCurrentVersion())
|
||||
assert.EqualValues(t, expect.Version+1, store.NextVersion())
|
||||
assert.Equal(t, expect, got)
|
||||
assert.Equal(t, expect, store.LastCommitID())
|
||||
|
||||
|
||||
+2
-2
@@ -13,12 +13,12 @@ import (
|
||||
type MultiStore interface {
|
||||
|
||||
// Last commit, or the zero CommitID.
|
||||
// If not zero, CommitID.Version is CurrentVersion()-1.
|
||||
// If not zero, CommitID.Version is NextVersion()-1.
|
||||
LastCommitID() CommitID
|
||||
|
||||
// Current version being worked on now, not yet committed.
|
||||
// Should be greater than 0.
|
||||
CurrentVersion() int64
|
||||
NextVersion() int64
|
||||
|
||||
// Cache wrap MultiStore.
|
||||
// NOTE: Caller should probably not call .Write() on each, but
|
||||
|
||||
Reference in New Issue
Block a user