github.com/sixexorg/magnetic-ring@v0.0.0-20191119090307-31705a21e419/store/orgchain/vm_storages/contract_store.go (about) 1 package vm_storages 2 3 import ( 4 "github.com/sixexorg/magnetic-ring/common" 5 "github.com/sixexorg/magnetic-ring/store/db" 6 ) 7 8 type ContractStore struct { 9 dbDir string 10 store *db.LevelDBStore 11 } 12 13 func NewContractStore(dbDir string) (*ContractStore, error) { 14 var err error 15 store, err := db.NewLevelDBStore(dbDir) 16 if err != nil { 17 return nil, err 18 } 19 voteStore := &ContractStore{ 20 dbDir: dbDir, 21 store: store, 22 } 23 return voteStore, nil 24 } 25 26 func (this *ContractStore) Save(contract []byte, address common.Address) error { 27 return this.store.Put(address[:], contract) 28 } 29 30 func (this *ContractStore) Get(address common.Address) ([]byte, error) { 31 return this.store.Get(address[:]) 32 }