From b802e1e2a78332a2810b738574bd94cf507f4edf Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 8 Jun 2023 17:32:01 +0200 Subject: [PATCH] fix: bugs --- p2p/module.go | 9 +++++++-- p2p/providers/peerstore_provider/persistence/provider.go | 6 ++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/p2p/module.go b/p2p/module.go index 032d2fa173..359cab5d07 100644 --- a/p2p/module.go +++ b/p2p/module.go @@ -229,14 +229,19 @@ func (m *p2pModule) setupDependencies() error { // setupPeerstoreProvider attempts to retrieve the peerstore provider from the // bus, if one is registered, otherwise returns a new `persistencePeerstoreProvider`. -func (m *p2pModule) setupPeerstoreProvider() (err error) { +func (m *p2pModule) setupPeerstoreProvider() error { m.logger.Debug().Msg("setupPeerstoreProvider") // TECHDEBT(#810): simplify once submodules are more convenient to retrieve. pstoreProviderModule, err := m.GetBus().GetModulesRegistry().GetModule(peerstore_provider.ModuleName) if err != nil { m.logger.Debug().Msg("creating new persistence peerstore...") - m.pstoreProvider, err = persPSP.NewPersistencePeerstoreProvider(m.GetBus()) + pstoreProvider, err := persPSP.NewPersistencePeerstoreProvider(m.GetBus()) + if err != nil { + return err + } + + m.pstoreProvider = pstoreProvider return nil } diff --git a/p2p/providers/peerstore_provider/persistence/provider.go b/p2p/providers/peerstore_provider/persistence/provider.go index 9c45203bca..caf4dc094d 100644 --- a/p2p/providers/peerstore_provider/persistence/provider.go +++ b/p2p/providers/peerstore_provider/persistence/provider.go @@ -7,13 +7,15 @@ import ( "github.com/pokt-network/pocket/shared/modules/base_modules" ) -var _ peerstore_provider.PeerstoreProvider = &persistencePeerstoreProvider{} +var ( + _ peerstore_provider.PeerstoreProvider = &persistencePeerstoreProvider{} + _ persistencePStoreProviderFactory = &persistencePeerstoreProvider{} +) type persistencePStoreProviderOption func(*persistencePeerstoreProvider) type persistencePStoreProviderFactory = modules.FactoryWithOptions[peerstore_provider.PeerstoreProvider, persistencePStoreProviderOption] type persistencePeerstoreProvider struct { base_modules.IntegratableModule - persistencePStoreProviderFactory } func NewPersistencePeerstoreProvider(bus modules.Bus, options ...persistencePStoreProviderOption) (peerstore_provider.PeerstoreProvider, error) {