From 0be4f0d8ae576dada1bd1a8dea40a86b333ffe31 Mon Sep 17 00:00:00 2001 From: Ryan Orendorff <12442942+ryanorendorff@users.noreply.github.com> Date: Mon, 5 Jun 2023 10:26:04 -0600 Subject: [PATCH 1/2] Use YAML list for enabled/disabled methods Prior a string with a delimiter (`,`) was used for enabling and disabling methods. YAML has a built in list type, so this change enables the use of that. --- internal/config/config.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index 06fb3e2b..dbbe544a 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -3,7 +3,6 @@ package config import ( "errors" "os" - "strings" "go.uber.org/zap" "gopkg.in/yaml.v3" @@ -104,8 +103,8 @@ type MethodsConfig struct { func (m *MethodsConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { type MethodsConfigString struct { - Enabled string - Disabled string + Enabled []string + Disabled []string } var methodsConfigString MethodsConfigString @@ -116,12 +115,12 @@ func (m *MethodsConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { } m.Enabled = make(map[string]bool) - for _, method := range strings.Split(methodsConfigString.Enabled, ",") { + for _, method := range methodsConfigString.Enabled { m.Enabled[method] = true } m.Disabled = make(map[string]bool) - for _, method := range strings.Split(methodsConfigString.Disabled, ",") { + for _, method := range methodsConfigString.Disabled { m.Disabled[method] = true } From 51f27d75b8aa92e58a9d97ab89cb50871437b72b Mon Sep 17 00:00:00 2001 From: Ryan Orendorff <12442942+ryanorendorff@users.noreply.github.com> Date: Mon, 5 Jun 2023 10:35:22 -0600 Subject: [PATCH 2/2] Update tests for methods list --- internal/config/config_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/config/config_test.go b/internal/config/config_test.go index ecfb20c3..24714e60 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -203,8 +203,11 @@ func TestParseConfig_ValidConfig(t *testing.T) { group: primary nodeType: full methods: - enabled: eth_getStorageAt - disabled: eth_getBalance,getLogs + enabled: + - eth_getStorageAt + disabled: + - eth_getBalance + - getLogs - id: ankr-polygon httpURL: "https://rpc.ankr.com/polygon" wsURL: "wss://rpc.ankr.com/polygon/ws/${ANKR_API_KEY}"