From 51f200a698a2ec366657b1c4e89cfe7c5dd7e25f Mon Sep 17 00:00:00 2001 From: Daniel N <2color@users.noreply.github.com> Date: Wed, 25 Sep 2024 14:50:27 +0200 Subject: [PATCH] fix: rename to protocolsAllowed for readability --- routing/http/server/filters.go | 5 +++-- routing/http/server/filters_test.go | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/routing/http/server/filters.go b/routing/http/server/filters.go index 61c2613df..ccec45230 100644 --- a/routing/http/server/filters.go +++ b/routing/http/server/filters.go @@ -107,7 +107,7 @@ func applyFilters(provider *types.PeerRecord, filterAddrs, filterProtocols []str return provider } - if !applyProtocolFilter(provider.Protocols, filterProtocols) { + if !protocolsAllowed(provider.Protocols, filterProtocols) { // If the provider doesn't match any of the passed protocols, the provider is omitted from the response. return nil } @@ -177,7 +177,8 @@ func containsProtocol(protos []multiaddr.Protocol, proto multiaddr.Protocol) boo return false } -func applyProtocolFilter(peerProtocols []string, filterProtocols []string) bool { +// protocolsAllowed returns true if the peerProtocols are allowed by the filter protocols. +func protocolsAllowed(peerProtocols []string, filterProtocols []string) bool { if len(filterProtocols) == 0 { // If no filter is passed, do not filter return true diff --git a/routing/http/server/filters_test.go b/routing/http/server/filters_test.go index 3fcda11a5..04f9b7354 100644 --- a/routing/http/server/filters_test.go +++ b/routing/http/server/filters_test.go @@ -121,7 +121,7 @@ func TestApplyAddrFilter(t *testing.T) { } } -func TestApplyProtocolFilter(t *testing.T) { +func TestProtocolsAllowed(t *testing.T) { testCases := []struct { name string peerProtocols []string @@ -174,7 +174,7 @@ func TestApplyProtocolFilter(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - result := applyProtocolFilter(tc.peerProtocols, tc.filterProtocols) + result := protocolsAllowed(tc.peerProtocols, tc.filterProtocols) assert.Equal(t, tc.expected, result, "Unexpected result for test case: %s", tc.name) }) }