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 {
var err error err = walletdb.Update(w.db, func(
for _, rec := range n.RelevantTxs { tx walletdb.ReadWriteTx) error {
err = w.addRelevantTx(tx, rec, n.Block) var err error
if err != nil { for _, rec := range n.RelevantTxs {
return err err = w.addRelevantTx(tx, rec,
n.Block)
if err != nil {
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.