core: accept two-side channels for sub/unsub, read on unsub
Blockchain's notificationDispatcher sends events to channels and these channels must be read from. Unfortunately, regular service shutdown procedure does unsubscription first (outside of the read loop) and only then drains the channel. While it waits for unsubscription request to be accepted notificationDispatcher can try pushing more data into the same channel which will lead to a deadlock. Reading in the same method solves this, any number of events can be pushed until unsub channel accepts the data.
This commit is contained in:
parent
dea75a4211
commit
eeeb0f6f0e
7 changed files with 83 additions and 53 deletions
|
@ -69,8 +69,8 @@ type (
|
|||
PoolTx(t *transaction.Transaction, pools ...*mempool.Pool) error
|
||||
PoolTxWithData(t *transaction.Transaction, data interface{}, mp *mempool.Pool, feer mempool.Feer, verificationFunction func(t *transaction.Transaction, data interface{}) error) error
|
||||
RegisterPostBlock(f func(func(*transaction.Transaction, *mempool.Pool, bool) bool, *mempool.Pool, *block.Block))
|
||||
SubscribeForBlocks(ch chan<- *block.Block)
|
||||
UnsubscribeFromBlocks(ch chan<- *block.Block)
|
||||
SubscribeForBlocks(ch chan *block.Block)
|
||||
UnsubscribeFromBlocks(ch chan *block.Block)
|
||||
}
|
||||
|
||||
// Service is a service abstraction (oracle, state root, consensus, etc).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue