Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion walletapi/daemon_communication.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func (w *Wallet_Memory) Sync_Wallet_Memory_With_Daemon_internal(scid crypto.Hash
w.Lock()
w.account.Balance[scid] = b
w.Unlock()
w.SyncHistory(scid) // also update statement
go w.SyncHistory(scid) // also update statement (run in background to avoid blocking sync loop)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest coalescing instead of unconditional spawn, so repeated balance changes during a long scan don't queue goroutines on sync_multilock (needs a synchistory_pending int32 field and sync/atomic import):

if atomic.CompareAndSwapInt32(&w.synchistory_pending, 0, 1) {
	go func() {
		defer atomic.StoreInt32(&w.synchistory_pending, 0)
		w.SyncHistory(scid)
	}()
}

}

w.save_if_disk() // save wallet
Expand Down