contractcourt: make synchronous chain watcher notifications optional

In this commit, we modify the way that notifications are dispatched
within the chainWatcher. Before we would *always* wait for an ack back
before we started to clean up he database state. This would at times
lead to deadlocks. To remedy this, we now allow callers to decide if
they want notifications to be sync or not. The only current caller that
requires this is the breach arbiter.
This commit is contained in:
Olaoluwa Osuntokun committed 2018-01-22 19:19:58 -08:00
1 parent f85f1f97ca
commit 5df6704a9c
5 files changed
+57 -31

No files matched your search

+6 -2
View File
@@ -370,7 +370,9 @@ func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) error {
// Register this new channel link with the HTLC Switch. This is
// necessary to properly route multi-hop payments, and forward
// new payments triggered by RPC clients.
chainEvents, err := p.server.chainArb.SubscribeChannelEvents(*chanPoint)
chainEvents, err := p.server.chainArb.SubscribeChannelEvents(
*chanPoint, false,
)
if err != nil {
return err
}
@@ -1259,7 +1261,9 @@ out:
peerLog.Errorf("unable to get best block: %v", err)
continue
}
chainEvents, err := p.server.chainArb.SubscribeChannelEvents(*chanPoint)
chainEvents, err := p.server.chainArb.SubscribeChannelEvents(
*chanPoint, false,
)
if err != nil {
peerLog.Errorf("unable to subscribe to chain "+
"events: %v", err)