diff --git a/net/peer.go b/net/peer.go index 3173508..9f3c55b 100644 --- a/net/peer.go +++ b/net/peer.go @@ -47,7 +47,7 @@ type Peer interface { IsHandshakeDone() bool SetHandshakeDone(status bool) GetIP() string - Abused() bool + Abuser() bool } type BasePeer struct { @@ -127,6 +127,6 @@ func (b *BasePeer) SetHandshakeDone(status bool) { b.handshaked = status } -func (b *BasePeer) Abused() bool { +func (b *BasePeer) Abuser() bool { panic("must implement in child class") } diff --git a/net/ws.go b/net/ws.go index 95e15de..bb8e167 100644 --- a/net/ws.go +++ b/net/ws.go @@ -16,7 +16,7 @@ var ( type WebSocketPeer struct { BasePeer socket *websocket.Conn - abused bool + abuser bool } func (p *WebSocketPeer) Connect(uri *url.URL) (interface{}, error) { @@ -105,7 +105,7 @@ func (p *WebSocketPeer) End() error { return nil } func (p *WebSocketPeer) EndForAbuse() error { - p.abused = true + p.abuser = true err := p.socket.Close(websocket.StatusPolicyViolation, "") if err != nil { return err @@ -135,6 +135,6 @@ func (b *WebSocketPeer) GetIP() string { return ipAddr } -func (p *WebSocketPeer) Abused() bool { - return p.abused +func (p *WebSocketPeer) Abuser() bool { + return p.abuser } diff --git a/service/p2p.go b/service/p2p.go index e9c9516..f4e0435 100644 --- a/service/p2p.go +++ b/service/p2p.go @@ -329,7 +329,7 @@ func (p *P2PImpl) ConnectToNode(connectionUris []*url.URL, retried bool, fromPee go func() { err := p.OnNewPeer(peer, true) - if err != nil && !peer.Abused() { + if err != nil && !peer.Abuser() { p.logger.Error("peer error", zap.Error(err)) } p.Node().ConnectionTracker().Done() @@ -424,7 +424,7 @@ func (p *P2PImpl) OnNewPeerListen(peer net.Peer, verifyId bool) { }) onError := net.ErrorCallback(func(args ...interface{}) { - if !peer.Abused() { + if !peer.Abuser() { p.logger.Error("peer error", zap.Any("args", args)) } })