From 00a7f140ff6b3d12d9fbe0bb3652ff094ae4124c Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sun, 23 Apr 2017 19:29:38 -0700 Subject: [PATCH] peer: add WaitForDisconnect method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds a new method to the peer struct: WaitForDisconnect(). This method is put in place to be used by wallers to synchronize the ending of a peer’s lifetime. A follow up commit will utilize this new method to re-write the way we handle persistent peer connections. --- peer.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/peer.go b/peer.go index c51de2b8..fd7c0f89 100644 --- a/peer.go +++ b/peer.go @@ -319,7 +319,13 @@ func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) error { return nil } -// TODO(roasbeef): add WaitForShutdown method +// WaitForDisconnect waits until the peer has disconnected. A peer may be +// disconnected if the local or remote side terminating the connection, or an +// irrecoverable protocol error has been encountered. +func (p *peer) WaitForDisconnect() { + <-p.quit + +} // Disconnect terminates the connection with the remote peer. Additionally, a // signal is sent to the server and htlcSwitch indicating the resources