Fuse with if above

This commit is contained in:
Marco Munizaga 2022-06-27 13:59:26 -07:00
parent a41033230f
commit 1bf5e930ee

View File

@ -590,18 +590,18 @@ func (s *connectionScope) SetPeer(p peer.ID) error {
if s.isAllowlisted {
system = s.rcmgr.allowlistedSystem
transient = s.rcmgr.transient
}
if s.isAllowlisted && !s.rcmgr.allowlist.AllowedPeerAndMultiaddr(p, s.endpoint) {
// This is not an allowed peer + multiaddr combination. We need to
// transfer this connection to the general scope. We'll do this first by
// transferring the connection to the system and transient scopes, then
// continue on with this function. The idea is that a connection
// shouldn't get the benefit of evading the transient scope because it
// was _almost_ an allowlisted connection.
if err := s.transferAllowedToStandard(); err != nil {
// Failed to transfer this connection to the standard scopes
return err
if !s.rcmgr.allowlist.AllowedPeerAndMultiaddr(p, s.endpoint) {
// This is not an allowed peer + multiaddr combination. We need to
// transfer this connection to the general scope. We'll do this first by
// transferring the connection to the system and transient scopes, then
// continue on with this function. The idea is that a connection
// shouldn't get the benefit of evading the transient scope because it
// was _almost_ an allowlisted connection.
if err := s.transferAllowedToStandard(); err != nil {
// Failed to transfer this connection to the standard scopes
return err
}
}
}