good morning!!!!

Skip to content
Snippets Groups Projects
Commit f0f67277 authored by Felix Lange's avatar Felix Lange
Browse files

p2p: use an error type for disconnect requests

Test-tastic.
parent 65e39bf2
No related branches found
No related tags found
No related merge requests found
......@@ -100,7 +100,16 @@ func (d DiscReason) String() string {
return discReasonToString[d]
}
type discRequestedError DiscReason
func (err discRequestedError) Error() string {
return fmt.Sprintf("disconnect requested: %v", DiscReason(err))
}
func discReasonForError(err error) DiscReason {
if reason, ok := err.(discRequestedError); ok {
return DiscReason(reason)
}
peerError, ok := err.(*peerError)
if !ok {
return DiscSubprotocolError
......
......@@ -158,8 +158,7 @@ func (bp *baseProtocol) handle(rw MsgReadWriter) error {
if err := msg.Decode(&reason); err != nil {
return err
}
bp.peer.Disconnect(reason[0])
return nil
return discRequestedError(reason[0])
case pingMsg:
return bp.rw.EncodeMsg(pongMsg)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment