From 5b0cfb2f3ae551f5b3f911f6e4836bc5f4ef3169 Mon Sep 17 00:00:00 2001 From: Arash Deshmeh Date: Wed, 2 Aug 2023 10:05:27 -0400 Subject: [PATCH 1/3] Add servicer module mock --- shared/modules/servicer_module.go | 16 ++++++++++++++++ shared/modules/utility_module.go | 5 ----- utility/module.go | 4 ++-- 3 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 shared/modules/servicer_module.go diff --git a/shared/modules/servicer_module.go b/shared/modules/servicer_module.go new file mode 100644 index 000000000..657a5003c --- /dev/null +++ b/shared/modules/servicer_module.go @@ -0,0 +1,16 @@ +package modules + +//go:generate mockgen -destination=./mocks/servicer_module_mock.go github.com/pokt-network/pocket/shared/modules ServicerModule + +import ( + coreTypes "github.com/pokt-network/pocket/shared/core/types" +) + +const ( + ServicerModuleName = "servicer" +) + +type ServicerModule interface { + Module + HandleRelay(*coreTypes.Relay) (*coreTypes.RelayResponse, error) +} diff --git a/shared/modules/utility_module.go b/shared/modules/utility_module.go index 720a4fa09..24e1c9779 100644 --- a/shared/modules/utility_module.go +++ b/shared/modules/utility_module.go @@ -62,11 +62,6 @@ type FishermanModule interface { Module } -type ServicerModule interface { - Module - HandleRelay(*coreTypes.Relay) (*coreTypes.RelayResponse, error) -} - type ValidatorModule interface { Module } diff --git a/utility/module.go b/utility/module.go index c8b027b9e..6ffffdb7f 100644 --- a/utility/module.go +++ b/utility/module.go @@ -142,10 +142,10 @@ func (u *utilityModule) GetActorModules() map[string]modules.Module { } func (u *utilityModule) GetServicerModule() (modules.ServicerModule, error) { - if u.actorModules[servicer.ServicerModuleName] == nil { + if u.actorModules[modules.ServicerModuleName] == nil { return nil, errors.New("servicer module not enabled") } - if m, ok := u.actorModules[servicer.ServicerModuleName].(modules.ServicerModule); ok { + if m, ok := u.actorModules[modules.ServicerModuleName].(modules.ServicerModule); ok { return m, nil } return nil, errors.New("failed to cast servicer module") From 35ec32d811f50b04409d5a91ea94ce3df28fc5e5 Mon Sep 17 00:00:00 2001 From: Arash Deshmeh Date: Wed, 2 Aug 2023 12:47:17 -0400 Subject: [PATCH 2/3] Remove unused module name variable --- utility/servicer/module.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/utility/servicer/module.go b/utility/servicer/module.go index 18871633d..4df87d6d5 100644 --- a/utility/servicer/module.go +++ b/utility/servicer/module.go @@ -35,10 +35,6 @@ var ( _ modules.ServicerModule = &servicer{} ) -const ( - ServicerModuleName = "servicer" -) - // sessionTokens is used to cache the starting number of tokens available // during a specific session: it is used as the value for a map with keys being applications' public keys // TODO: What if we have a servicer managing more than one session from the same app at once? We may/may not need to resolve this in the future. @@ -121,7 +117,7 @@ func (s *servicer) Stop() error { } func (s *servicer) GetModuleName() string { - return ServicerModuleName + return modules.ServicerModuleName } // HandleRelay processes a relay after performing validation. From bbb594f652ce175c5ce412c7e1d5158ae5d29470 Mon Sep 17 00:00:00 2001 From: Arash Deshmeh Date: Wed, 9 Aug 2023 10:12:59 -0400 Subject: [PATCH 3/3] Move actors shared modules to independent files --- shared/modules/fisherman_module.go | 5 +++++ shared/modules/utility_module.go | 8 -------- shared/modules/validator_module.go | 5 +++++ 3 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 shared/modules/fisherman_module.go create mode 100644 shared/modules/validator_module.go diff --git a/shared/modules/fisherman_module.go b/shared/modules/fisherman_module.go new file mode 100644 index 000000000..fbc96ed5b --- /dev/null +++ b/shared/modules/fisherman_module.go @@ -0,0 +1,5 @@ +package modules + +type FishermanModule interface { + Module +} diff --git a/shared/modules/utility_module.go b/shared/modules/utility_module.go index 24e1c9779..4594ee295 100644 --- a/shared/modules/utility_module.go +++ b/shared/modules/utility_module.go @@ -58,14 +58,6 @@ type UtilityModule interface { GetValidatorModule() (ValidatorModule, error) } -type FishermanModule interface { - Module -} - -type ValidatorModule interface { - Module -} - // TECHDEBT: Remove this interface from `shared/modules` and use the `Actor` protobuf type instead // There will need to be some documentation or indicator that the Actor struct returned may not be // fully hydrated. Alternatively, we could eat the performance cost and just hydrate the entire struct diff --git a/shared/modules/validator_module.go b/shared/modules/validator_module.go new file mode 100644 index 000000000..b29b21c09 --- /dev/null +++ b/shared/modules/validator_module.go @@ -0,0 +1,5 @@ +package modules + +type ValidatorModule interface { + Module +}