Skip to content

Commit

Permalink
chore: implement PeerstoreProvider#GetUnstakedPeerstore()
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanchriswhite committed Jul 13, 2023
1 parent 0e9d233 commit 8a531e4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 36 deletions.
15 changes: 14 additions & 1 deletion p2p/providers/peerstore_provider/persistence/provider.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package persistence

import (
"fmt"

"github.com/pokt-network/pocket/p2p/providers/peerstore_provider"
typesP2P "github.com/pokt-network/pocket/p2p/types"
"github.com/pokt-network/pocket/shared/modules"
Expand Down Expand Up @@ -58,5 +60,16 @@ func (persistencePSP *persistencePeerstoreProvider) GetStakedPeerstoreAtHeight(h

// GetStakedPeerstoreAtHeight implements the respective `PeerstoreProvider` interface method.
func (persistencePSP *persistencePeerstoreProvider) GetUnstakedPeerstore() (typesP2P.Peerstore, error) {
return peerstore_provider.GetUnstakedPeerstore(persistencePSP.GetBus())
// TECHDEBT(#810, #811): use `bus.GetUnstakedActorRouter()` once it's available.
unstakedActorRouterMod, err := persistencePSP.GetBus().GetModulesRegistry().GetModule(typesP2P.UnstakedActorRouterSubmoduleName)
if err != nil {
return nil, err
}

unstakedActorRouter, ok := unstakedActorRouterMod.(typesP2P.Router)
if !ok {
return nil, fmt.Errorf("unexpected unstaked actor router submodule type: %T", unstakedActorRouterMod)
}

return unstakedActorRouter.GetPeerstore(), nil
}
13 changes: 12 additions & 1 deletion p2p/providers/peerstore_provider/rpc/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,18 @@ func (rpcPSP *rpcPeerstoreProvider) GetStakedPeerstoreAtHeight(height uint64) (t
}

func (rpcPSP *rpcPeerstoreProvider) GetUnstakedPeerstore() (typesP2P.Peerstore, error) {
return peerstore_provider.GetUnstakedPeerstore(rpcPSP.GetBus())
// TECHDEBT(#810, #811): use `bus.GetUnstakedActorRouter()` once it's available.
unstakedActorRouterMod, err := rpcPSP.GetBus().GetModulesRegistry().GetModule(typesP2P.UnstakedActorRouterSubmoduleName)
if err != nil {
return nil, err
}

unstakedActorRouter, ok := unstakedActorRouterMod.(typesP2P.Router)
if !ok {
return nil, fmt.Errorf("unexpected unstaked actor router submodule type: %T", unstakedActorRouterMod)
}

return unstakedActorRouter.GetPeerstore(), nil
}

func (rpcPSP *rpcPeerstoreProvider) initRPCClient() {
Expand Down
34 changes: 0 additions & 34 deletions p2p/providers/peerstore_provider/unstaked.go

This file was deleted.

0 comments on commit 8a531e4

Please sign in to comment.