contractcourt: notify blockbeat for chainWatcher
We now start notifying the blockbeat from the ChainArbitrator to the chainWatcher.
This commit is contained in:
1 file changed
+16
-1
@@ -727,19 +727,34 @@ func (c *ChainArbitrator) handleBlockbeat(beat chainio.Blockbeat) {
|
|||||||
|
|
||||||
// Create a slice to record active channel arbitrator.
|
// Create a slice to record active channel arbitrator.
|
||||||
channels := make([]chainio.Consumer, 0, len(c.activeChannels))
|
channels := make([]chainio.Consumer, 0, len(c.activeChannels))
|
||||||
|
watchers := make([]chainio.Consumer, 0, len(c.activeWatchers))
|
||||||
|
|
||||||
// Copy the active channels to the slice.
|
// Copy the active channels to the slice.
|
||||||
for _, channel := range c.activeChannels {
|
for _, channel := range c.activeChannels {
|
||||||
channels = append(channels, channel)
|
channels = append(channels, channel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, watcher := range c.activeWatchers {
|
||||||
|
watchers = append(watchers, watcher)
|
||||||
|
}
|
||||||
|
|
||||||
c.Unlock()
|
c.Unlock()
|
||||||
|
|
||||||
|
// Iterate all the copied watchers and send the blockbeat to them.
|
||||||
|
err := chainio.DispatchConcurrent(beat, watchers)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Notify blockbeat for chainWatcher failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
// Iterate all the copied channels and send the blockbeat to them.
|
// Iterate all the copied channels and send the blockbeat to them.
|
||||||
//
|
//
|
||||||
// NOTE: This method will timeout if the processing of blocks of the
|
// NOTE: This method will timeout if the processing of blocks of the
|
||||||
// subsystems is too long (60s).
|
// subsystems is too long (60s).
|
||||||
err := chainio.DispatchConcurrent(beat, channels)
|
err = chainio.DispatchConcurrent(beat, channels)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Notify blockbeat for ChannelArbitrator failed: %v",
|
||||||
|
err)
|
||||||
|
}
|
||||||
|
|
||||||
// Notify the chain arbitrator has processed the block.
|
// Notify the chain arbitrator has processed the block.
|
||||||
c.NotifyBlockProcessed(beat, err)
|
c.NotifyBlockProcessed(beat, err)
|
||||||
|
|||||||
Reference in new issue
Block a user