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:
parent
49f6b7d35d
commit
0ba8cb9187
1 changed files with 5 additions and 3 deletions
|
@ -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
|
||||
}()
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue