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)