2018-01-22 05:44:24 -08:00
|
|
|
package store
|
|
|
|
|
|
|
|
import (
|
2018-07-12 16:58:51 -07:00
|
|
|
"io"
|
|
|
|
|
2018-01-22 05:44:24 -08:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2018-07-02 13:34:06 -07:00
|
|
|
dbm "github.com/tendermint/tendermint/libs/db"
|
2018-01-22 05:44:24 -08:00
|
|
|
)
|
|
|
|
|
|
|
|
type dbStoreAdapter struct {
|
|
|
|
dbm.DB
|
|
|
|
}
|
|
|
|
|
|
|
|
// Implements Store.
|
2018-04-18 21:49:24 -07:00
|
|
|
func (dbStoreAdapter) GetStoreType() StoreType {
|
2018-01-22 05:44:24 -08:00
|
|
|
return sdk.StoreTypeDB
|
|
|
|
}
|
|
|
|
|
|
|
|
// Implements KVStore.
|
|
|
|
func (dsa dbStoreAdapter) CacheWrap() CacheWrap {
|
|
|
|
return NewCacheKVStore(dsa)
|
|
|
|
}
|
|
|
|
|
2018-07-12 16:58:51 -07:00
|
|
|
// CacheWrapWithTrace implements the KVStore interface.
|
|
|
|
func (dsa dbStoreAdapter) CacheWrapWithTrace(w io.Writer, tc TraceContext) CacheWrap {
|
|
|
|
return NewCacheKVStore(NewTraceKVStore(dsa, w, tc))
|
|
|
|
}
|
|
|
|
|
2018-06-21 14:33:36 -07:00
|
|
|
// Implements KVStore
|
|
|
|
func (dsa dbStoreAdapter) Prefix(prefix []byte) KVStore {
|
|
|
|
return prefixStore{dsa, prefix}
|
|
|
|
}
|
|
|
|
|
2018-01-22 05:44:24 -08:00
|
|
|
// dbm.DB implements KVStore so we can CacheKVStore it.
|
|
|
|
var _ KVStore = dbStoreAdapter{dbm.DB(nil)}
|