From f2716384228860e8db0ee6adf0b2d4ce6598be11 Mon Sep 17 00:00:00 2001 From: erinn Date: Wed, 10 Oct 2018 14:59:38 -0700 Subject: [PATCH] reduce waituntilauthenticated delay and add one for psc --- peer/connections/peerpeerconnection.go | 2 +- peer/connections/peerserverconnection.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/peer/connections/peerpeerconnection.go b/peer/connections/peerpeerconnection.go index 04124e1..8368fd3 100644 --- a/peer/connections/peerpeerconnection.go +++ b/peer/connections/peerpeerconnection.go @@ -95,7 +95,7 @@ func (ppc *PeerPeerConnection) WaitTilAuthenticated() { if ppc.GetState() == AUTHENTICATED { break } - time.Sleep(time.Second * 5) + time.Sleep(time.Second * 1) } } diff --git a/peer/connections/peerserverconnection.go b/peer/connections/peerserverconnection.go index 1ab8547..0b5bcce 100644 --- a/peer/connections/peerserverconnection.go +++ b/peer/connections/peerserverconnection.go @@ -39,6 +39,16 @@ func (psc *PeerServerConnection) GetState() ConnectionState { return psc.state } +// WaitTilAuthenticated waits until the underlying connection is authenticated +func (psc *PeerServerConnection) WaitTilAuthenticated() { + for { + if psc.GetState() == AUTHENTICATED { + break + } + time.Sleep(time.Second * 1) + } +} + // Run manages the setup and teardown of a peer server connection func (psc *PeerServerConnection) Run() error { log.Printf("Connecting to %v", psc.Server)