Skip to content

Commit 0a53a74

Browse files
committed
ARCO-105: Move functions
1 parent 59f9ee8 commit 0a53a74

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

peer.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -855,26 +855,6 @@ func (p *Peer) IsHealthy() bool {
855855
return p.isHealthy.Load()
856856
}
857857

858-
func (p *Peer) stopReadHandler() {
859-
if p.cancelReadHandler == nil {
860-
return
861-
}
862-
p.logger.Debug("Cancelling read handlers")
863-
p.cancelReadHandler()
864-
p.logger.Debug("Waiting for read handlers to stop")
865-
p.readerWg.Wait()
866-
}
867-
868-
func (p *Peer) stopWriteHandler() {
869-
if p.cancelWriteHandler == nil {
870-
return
871-
}
872-
p.logger.Debug("Cancelling write handlers")
873-
p.cancelWriteHandler()
874-
p.logger.Debug("Waiting for writer handlers to stop")
875-
p.writerWg.Wait()
876-
}
877-
878858
func (p *Peer) Restart() {
879859
p.Shutdown()
880860

peer_test.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,10 @@ func TestReconnect(t *testing.T) {
333333

334334
if tc.cancelRead {
335335
// cancel reader so that writer will disconnect
336-
peer.stopReadHandler()
336+
stopReadHandler(peer)
337337
} else {
338338
// cancel writer so that reader will disconnect
339-
peer.stopWriteHandler()
339+
stopWriteHandler(peer)
340340
}
341341

342342
// break connection
@@ -637,3 +637,23 @@ func doHandshake(t *testing.T, p *Peer, myConn net.Conn) {
637637
assert.NoError(t, err)
638638
assert.Equal(t, wire.CmdVerAck, msg.Command())
639639
}
640+
641+
func stopReadHandler(p *Peer) {
642+
if p.cancelReadHandler == nil {
643+
return
644+
}
645+
p.logger.Debug("Cancelling read handlers")
646+
p.cancelReadHandler()
647+
p.logger.Debug("Waiting for read handlers to stop")
648+
p.readerWg.Wait()
649+
}
650+
651+
func stopWriteHandler(p *Peer) {
652+
if p.cancelWriteHandler == nil {
653+
return
654+
}
655+
p.logger.Debug("Cancelling write handlers")
656+
p.cancelWriteHandler()
657+
p.logger.Debug("Waiting for writer handlers to stop")
658+
p.writerWg.Wait()
659+
}

0 commit comments

Comments
 (0)