func (store *WalletStore) DeleteTransactions(height uint64) {
tmpTx := query.AnnotatedTx{}
batch := store.DB.NewBatch()
+ if store.batch != nil {
+ batch = store.batch
+ }
txIter := store.DB.IteratorPrefix(calcDeleteKey(height))
defer txIter.Release()
}
batch.Delete(txIter.Key())
}
- batch.Write()
+ if store.batch == nil {
+ batch.Write()
+ }
}
// SetTransaction set raw transaction by block height and tx position
return err
}
+ w.store.InitBatch()
+ defer w.store.CommitBatch()
+
w.detachUtxos(block, txStatus)
w.store.DeleteTransactions(w.status.BestHeight)
w.status.WorkHeight = w.status.BestHeight
w.status.WorkHash = w.status.BestHash
}
+ err = w.commitWalletInfo()
- return w.commitWalletInfo()
+ return err
}
//WalletUpdate process every valid block and reverse every invalid block which need to rollback