OSDN Git Service

update wallet-store-interface-batch
authorChengcheng Zhang <943420582@qq.com>
Mon, 24 Jun 2019 11:49:31 +0000 (19:49 +0800)
committerChengcheng Zhang <943420582@qq.com>
Mon, 24 Jun 2019 11:49:31 +0000 (19:49 +0800)
database/wallet_store.go

index 93e2353..334882c 100644 (file)
@@ -165,15 +165,17 @@ func (store *WalletStore) GetAccountByAccountID(accountID string) []byte {
 // DeleteTransactions delete transactions when orphan block rollback
 func (store *WalletStore) DeleteTransactions(height uint64) {
        tmpTx := query.AnnotatedTx{}
+       batch := store.DB.NewBatch()
        txIter := store.DB.IteratorPrefix(calcDeleteKey(height))
        defer txIter.Release()
 
        for txIter.Next() {
                if err := json.Unmarshal(txIter.Value(), &tmpTx); err == nil {
-                       store.batch.Delete(calcTxIndexKey(tmpTx.ID.String()))
+                       batch.Delete(calcTxIndexKey(tmpTx.ID.String()))
                }
-               store.batch.Delete(txIter.Key())
+               batch.Delete(txIter.Key())
        }
+       batch.Write()
 }
 
 // SetTransaction set raw transaction by block height and tx position