github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/tm2/pkg/store/store.go (about) 1 package store 2 3 import ( 4 "fmt" 5 6 dbm "github.com/gnolang/gno/tm2/pkg/db" 7 "github.com/gnolang/gno/tm2/pkg/strings" 8 9 "github.com/gnolang/gno/tm2/pkg/store/rootmulti" 10 "github.com/gnolang/gno/tm2/pkg/store/types" 11 ) 12 13 func NewCommitMultiStore(db dbm.DB) types.CommitMultiStore { 14 return rootmulti.NewMultiStore(db) 15 } 16 17 func NewPruningOptionsFromString(strategy string) (opt PruningOptions) { 18 switch strategy { 19 case "nothing": 20 opt = PruneNothing 21 case "everything": 22 opt = PruneEverything 23 case "syncable": 24 opt = PruneSyncable 25 default: 26 opt = PruneSyncable 27 } 28 return 29 } 30 31 // TODO move to another file. 32 func Print(store Store) { 33 fmt.Println("//----------------------------------------") 34 fmt.Println("// store:", store) 35 itr := store.Iterator(nil, nil) 36 defer itr.Close() 37 for ; itr.Valid(); itr.Next() { 38 key, value := itr.Key(), itr.Value() 39 var keystr, valuestr string 40 if strings.IsASCIIText(string(key)) { 41 keystr = string(key) 42 } else { 43 keystr = fmt.Sprintf("0x%X", key) 44 } 45 if strings.IsASCIIText(string(value)) { 46 valuestr = string(value) 47 } else { 48 valuestr = fmt.Sprintf("0x%X", value) 49 } 50 fmt.Printf("%s: %s\n", keystr, valuestr) 51 } 52 }