2018-07-26 18:24:18 -07:00
|
|
|
package store
|
|
|
|
|
|
|
|
import (
|
2018-09-10 11:25:34 -07:00
|
|
|
dbm "github.com/tendermint/tendermint/libs/db"
|
2018-12-10 06:27:25 -08:00
|
|
|
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2018-07-26 18:24:18 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
var _ KVStore = (*transientStore)(nil)
|
|
|
|
|
|
|
|
// transientStore is a wrapper for a MemDB with Commiter implementation
|
|
|
|
type transientStore struct {
|
|
|
|
dbStoreAdapter
|
|
|
|
}
|
|
|
|
|
|
|
|
// Constructs new MemDB adapter
|
|
|
|
func newTransientStore() *transientStore {
|
|
|
|
return &transientStore{dbStoreAdapter{dbm.NewMemDB()}}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Implements CommitStore
|
|
|
|
// Commit cleans up transientStore.
|
|
|
|
func (ts *transientStore) Commit() (id CommitID) {
|
|
|
|
ts.dbStoreAdapter = dbStoreAdapter{dbm.NewMemDB()}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Implements CommitStore
|
|
|
|
func (ts *transientStore) SetPruning(pruning PruningStrategy) {
|
|
|
|
}
|
|
|
|
|
|
|
|
// Implements CommitStore
|
|
|
|
func (ts *transientStore) LastCommitID() (id CommitID) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Implements KVStore
|
|
|
|
func (ts *transientStore) Prefix(prefix []byte) KVStore {
|
|
|
|
return prefixStore{ts, prefix}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Implements KVStore
|
|
|
|
func (ts *transientStore) Gas(meter GasMeter, config GasConfig) KVStore {
|
|
|
|
return NewGasKVStore(meter, config, ts)
|
|
|
|
}
|
2018-09-08 17:47:36 -07:00
|
|
|
|
|
|
|
// Implements Store.
|
|
|
|
func (ts *transientStore) GetStoreType() StoreType {
|
|
|
|
return sdk.StoreTypeTransient
|
|
|
|
}
|