github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/tm2/pkg/store/dbadapter/store.go (about) 1 package dbadapter 2 3 import ( 4 dbm "github.com/gnolang/gno/tm2/pkg/db" 5 6 "github.com/gnolang/gno/tm2/pkg/store/cache" 7 "github.com/gnolang/gno/tm2/pkg/store/types" 8 ) 9 10 // Implements CommitStoreConstructor. 11 func StoreConstructor(db dbm.DB, opts types.StoreOptions) types.CommitStore { 12 return Store{ 13 DB: db, 14 } 15 } 16 17 // Wrapper type for dbm.Db with implementation of Store 18 type Store struct { 19 dbm.DB 20 } 21 22 // CacheWrap cache wraps the underlying store. 23 func (dsa Store) CacheWrap() types.Store { 24 return cache.New(dsa) 25 } 26 27 // Implements Store. 28 func (dsa Store) Write() { 29 // CacheWrap().Write() gets called, but not dsa.Write(). 30 panic("unexpected .Write() on dbadapter.Store.") 31 } 32 33 // Implements Committer/CommitStore. 34 func (dsa Store) Commit() types.CommitID { 35 // Always returns a zero commitID, as dbadapter store doesn't merkleize. 36 return types.CommitID{ 37 Version: 0, 38 Hash: nil, 39 } 40 } 41 42 // Implements Committer/CommitStore. 43 func (dsa Store) LastCommitID() types.CommitID { 44 // Always returns a zero commitID, as dbadapter store doesn't merkleize. 45 return types.CommitID{ 46 Version: 0, 47 Hash: nil, 48 } 49 } 50 51 // Implements Committer/CommitStore. 52 func (dsa Store) GetStoreOptions() types.StoreOptions { 53 return types.StoreOptions{} 54 } 55 56 // Implements Committer/CommitStore. 57 func (dsa Store) SetStoreOptions(types.StoreOptions) { 58 } 59 60 // Implements Committer/CommitStore. 61 func (dsa Store) LoadLatestVersion() error { 62 return nil 63 } 64 65 // Implements Committer/CommitStore. 66 func (dsa Store) LoadVersion(ver int64) error { 67 return nil 68 } 69 70 // dbm.DB implements Store. 71 var _ types.Store = Store{}