OSDN Git Service

add initBatch commitBatch
[bytom/vapor.git] / database / wallet_store.go
index dd41f3c..9d3bc41 100644 (file)
@@ -60,7 +60,8 @@ type WalletStorer interface {
 
 // WalletStore store wallet using leveldb
 type WalletStore struct {
-       DB dbm.DB
+       DB    dbm.DB
+       batch dbm.Batch
 }
 
 // NewWalletStore create new WalletStore struct
@@ -70,6 +71,18 @@ func NewWalletStore(db dbm.DB) *WalletStore {
        }
 }
 
+func (store *WalletStore) initBatch() {
+       if store.batch == nil {
+               store.batch = store.DB.NewBatch()
+       }
+}
+
+func (store *WalletStore) commitBatch() {
+       if store.batch != nil {
+               store.batch.Write()
+       }
+}
+
 // ContractKey account control promgram store prefix
 func ContractKey(hash common.Hash) []byte {
        return append([]byte(contractPrefix), hash[:]...)