wallet: eliminate some unneeded database transaction opens/commits

This commit is contained in:
Alex 2017-07-12 19:33:45 -06:00 committed by Olaoluwa Osuntokun
parent 4fb78bca18
commit fbde9a97c8

View file

@ -56,16 +56,21 @@ func (w *Wallet) handleChainNotifications() {
notificationName = "recvtx/redeemingtx" notificationName = "recvtx/redeemingtx"
case chain.FilteredBlockConnected: case chain.FilteredBlockConnected:
// Atomically update for the whole block. // Atomically update for the whole block.
err = walletdb.Update(w.db, func(tx walletdb.ReadWriteTx) error { if len(n.RelevantTxs) > 0 {
err = walletdb.Update(w.db, func(
tx walletdb.ReadWriteTx) error {
var err error var err error
for _, rec := range n.RelevantTxs { for _, rec := range n.RelevantTxs {
err = w.addRelevantTx(tx, rec, n.Block) err = w.addRelevantTx(tx, rec,
n.Block)
if err != nil { if err != nil {
return err return err
} }
} }
return nil return nil
}) })
}
notificationName = "filteredblockconnected"
// The following are handled by the wallet's rescan // The following are handled by the wallet's rescan
// goroutines, so just pass them there. // goroutines, so just pass them there.