-
Notifications
You must be signed in to change notification settings - Fork 33
/
p2p_module.go
35 lines (26 loc) · 1.37 KB
/
p2p_module.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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"
"google.golang.org/protobuf/types/known/anypb"
)
const P2PModuleName = "p2p"
type P2PModule interface {
Module
// Returns the public P2P address of this node
GetAddress() (cryptoPocket.Address, error)
// TECHDEBT(#811): uncomment after moving `typesP2P.Peerstore` interface to a shared package
// GetUnstakedPeerstore() (typesP2P.Peerstore, error)
// A network broadcast to all staked actors on the network using RainTree
Broadcast(msg *anypb.Any) error
// A direct asynchronous
Send(addr cryptoPocket.Address, msg *anypb.Any) error
// HandleEvent is used to react to events that occur inside the application
HandleEvent(*anypb.Any) error
// CONSIDERATION: The P2P module currently does implement a synchronous "request-response" pattern
// for core business logic between nodes. Rather, all communication is done
// asynchronously via a "fire-and-forget" pattern using `Send` and `Broadcast`.
// There are pros and cons to both, and future readers/maintainers/developers may
// consider the addition of a function similar to the one below.
// Request(addr cryptoPocket.Address, msg *anypb.Any) *anypb.Any
}