Skip to content

Commit

Permalink
feat: add P2PModule#GetConnections() interface method and impl.
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanchriswhite committed Jul 13, 2023
1 parent 12a5956 commit 8213d38
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions charts/pocket/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ config:
use_rain_tree: true
is_empty_connection_type: false
private_key: "" # @ignored This value is needed but ignored - use privateKeySecretKeyRef instead
# TODO: I think this has been renamed to `max_nonces`
max_mempool_count: 100000
enable_peer_discovery_debug_rpc: false
telemetry:
Expand Down
6 changes: 6 additions & 0 deletions p2p/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/libp2p/go-libp2p"
libp2pHost "github.com/libp2p/go-libp2p/core/host"
libp2pNetwork "github.com/libp2p/go-libp2p/core/network"
"github.com/multiformats/go-multiaddr"
"go.uber.org/multierr"
"google.golang.org/protobuf/proto"
Expand Down Expand Up @@ -274,6 +275,11 @@ func (m *p2pModule) GetAddress() (cryptoPocket.Address, error) {
return m.address, nil
}

// GetConnections implements the respective `modules.P2PModule` interface method.
func (m *p2pModule) GetConnections() []libp2pNetwork.Conn {
return m.host.Network().Conns()
}

// setupDependencies sets up the module's current height and peerstore providers.
func (m *p2pModule) setupDependencies() error {
if err := m.setupPeerstoreProvider(); err != nil {
Expand Down
8 changes: 7 additions & 1 deletion shared/modules/p2p_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package modules
//go:generate mockgen -destination=./mocks/p2p_module_mock.go github.com/pokt-network/pocket/shared/modules P2PModule

import (
cryptoPocket "github.com/pokt-network/pocket/shared/crypto"
libp2pNetwork "github.com/libp2p/go-libp2p/core/network"
"google.golang.org/protobuf/types/known/anypb"

cryptoPocket "github.com/pokt-network/pocket/shared/crypto"
)

const P2PModuleName = "p2p"
Expand All @@ -17,6 +19,10 @@ type P2PModule interface {
// TECHDEBT(#811): uncomment after moving `typesP2P.Peerstore` interface to a shared package
// GetUnstakedPeerstore() (typesP2P.Peerstore, error)

// GetConnections returns a list of all connections between the local libp2p
// host and connected remote peers.
GetConnections() []libp2pNetwork.Conn

// A network broadcast to all staked actors on the network using RainTree
Broadcast(msg *anypb.Any) error

Expand Down

0 comments on commit 8213d38

Please sign in to comment.