From 5d16a04a6678dcc9b4701ee6b3840e645fdb987e Mon Sep 17 00:00:00 2001 From: Rahul Ghangas Date: Tue, 2 Mar 2021 12:22:23 +0530 Subject: [PATCH] fix: If a message is filtered, exit but don't return error --- peer/gossip.go | 4 ++-- peer/sync.go | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/peer/gossip.go b/peer/gossip.go index 946d1cc..c156764 100644 --- a/peer/gossip.go +++ b/peer/gossip.go @@ -3,7 +3,6 @@ package peer import ( "context" "encoding/base64" - "fmt" "sync" "github.com/renproject/aw/channel" @@ -78,8 +77,9 @@ func (g *Gossiper) DidReceiveMessage(from id.Signatory, msg wire.Msg) error { case wire.MsgTypePull: g.didReceivePull(from, msg) case wire.MsgTypeSync: + //TODO: Fix Channel to gracefully handle the error returned if a message is filtered if g.filter.Filter(from, msg) { - return fmt.Errorf("denied gossip message from %v", from) + return nil } g.didReceiveSync(from, msg) } diff --git a/peer/sync.go b/peer/sync.go index bdb2a1e..3b1a229 100644 --- a/peer/sync.go +++ b/peer/sync.go @@ -153,8 +153,10 @@ func (syncer *Syncer) Sync(ctx context.Context, contentID []byte, hint *id.Signa func (syncer *Syncer) DidReceiveMessage(from id.Signatory, msg wire.Msg) error { if msg.Type == wire.MsgTypeSync { + //TODO: Fix Channel to not drop connection on first filtered message, + // since it could be a valid message that is simply late (comes after the grace period) if syncer.filter.Filter(from, msg) { - return fmt.Errorf("denied sync response from %v", from) + return nil } syncer.pendingMu.Lock() pending, ok := syncer.pending[string(msg.Data)]