Skip to content

Commit

Permalink
fix: If a message is filtered, exit but don't return error
Browse files Browse the repository at this point in the history
  • Loading branch information
Rahul Ghangas committed Mar 2, 2021
1 parent 875d475 commit 5d16a04
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions peer/gossip.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package peer
import (
"context"
"encoding/base64"
"fmt"
"sync"

"github.com/renproject/aw/channel"
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 3 additions & 1 deletion peer/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit 5d16a04

Please sign in to comment.