Send notification in their own goroutine.

Since the notification channel is provided by the caller and it may or may
not be buffered, send notifications in their own goroutine so the chain
processing code does not have to wait around on the caller to process the
notification before continuing.
This commit is contained in:
Dave Collins 2013-09-06 11:05:04 -05:00
parent 49f6b7d35d
commit 0ba8cb9187

View file

@ -70,7 +70,9 @@ func (b *BlockChain) sendNotification(typ NotificationType, data interface{}) {
return
}
// Generate and send the notification.
n := Notification{Type: typ, Data: data}
b.notifications <- &n
// Generate and send the notification asynchronously.
go func() {
n := Notification{Type: typ, Data: data}
b.notifications <- &n
}()
}