From b56656511f46765b67bf62db145a5214c2ca6aed Mon Sep 17 00:00:00 2001 From: Fabio Barone Date: Mon, 16 Dec 2019 17:13:11 -0500 Subject: [PATCH 1/2] p2p/protocols: change sequence of message accounting --- p2p/protocols/protocol.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/p2p/protocols/protocol.go b/p2p/protocols/protocol.go index 184a6923ab..e3aada8a3b 100644 --- a/p2p/protocols/protocol.go +++ b/p2p/protocols/protocol.go @@ -277,15 +277,18 @@ func (p *Peer) Send(ctx context.Context, msg interface{}) error { } size = len(r) } + + err = p2p.Send(p.rw, code, wmsg) + if err != nil { + return nil + } + // if the accounting hook is set, call it if p.spec.Hook != nil { err = p.spec.Hook.Send(p, uint32(size), msg) - if err != nil { - return err - } } - return p2p.Send(p.rw, code, wmsg) + return err } // handleIncoming(code) From 3ce83ab0dd0763003a75636b9a2a7f39a31ce6c6 Mon Sep 17 00:00:00 2001 From: Fabio Barone Date: Tue, 17 Dec 2019 08:45:45 -0500 Subject: [PATCH 2/2] p2p/accounting: fix err bug --- p2p/protocols/protocol.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/p2p/protocols/protocol.go b/p2p/protocols/protocol.go index e3aada8a3b..4308014f97 100644 --- a/p2p/protocols/protocol.go +++ b/p2p/protocols/protocol.go @@ -280,7 +280,7 @@ func (p *Peer) Send(ctx context.Context, msg interface{}) error { err = p2p.Send(p.rw, code, wmsg) if err != nil { - return nil + return err } // if the accounting hook is set, call it