Documentation ¶
Index ¶
- Constants
- func ConstructMessage(content []byte) []byte
- type Host
- type HostConfig
- type HostV2
- func (host *HostV2) AddPeer(p *Peer) error
- func (host *HostV2) AddStreamProtocol(protocols ...sttypes.Protocol)
- func (host *HostV2) C() (int, int, int)
- func (host *HostV2) Close() error
- func (host *HostV2) ConnectHostPeer(peer Peer) error
- func (host *HostV2) GetDiscovery() discovery.Discovery
- func (host *HostV2) GetID() libp2p_peer.ID
- func (host *HostV2) GetOrJoin(topic string) (*libp2p_pubsub.Topic, error)
- func (host *HostV2) GetP2PHost() libp2p_host.Host
- func (host *HostV2) GetPeerCount() int
- func (host *HostV2) GetSelfPeer() Peer
- func (host *HostV2) ListBlockedPeer() []libp2p_peer.ID
- func (host *HostV2) ListPeer(topic string) []libp2p_peer.ID
- func (host *HostV2) ListTopic() []string
- func (host *HostV2) Peerstore() libp2p_peerstore.Peerstore
- func (host *HostV2) PubSub() *libp2p_pubsub.PubSub
- func (host *HostV2) SendMessageToGroups(groups []nodeconfig.GroupID, msg []byte) (err error)
- func (host *HostV2) Start() error
- type NamedTopic
- type Peer
Constants ¶
const ( // SetAsideForConsensus set the number of active validation goroutines for the consensus topic SetAsideForConsensus = 1 << 13 // SetAsideOtherwise set the number of active validation goroutines for other topic SetAsideOtherwise = 1 << 11 // MaxMessageHandlers .. MaxMessageHandlers = SetAsideForConsensus + SetAsideOtherwise // MaxMessageSize is 2Mb MaxMessageSize = 1 << 21 )
Variables ¶
This section is empty.
Functions ¶
func ConstructMessage ¶
ConstructMessage constructs the p2p message as [messageType, contentSize, content]
Types ¶
type Host ¶
type Host interface { Start() error Close() error GetSelfPeer() Peer AddPeer(*Peer) error GetID() libp2p_peer.ID GetP2PHost() libp2p_host.Host GetDiscovery() discovery.Discovery GetPeerCount() int ConnectHostPeer(Peer) error // AddStreamProtocol add the given protocol AddStreamProtocol(protocols ...sttypes.Protocol) // SendMessageToGroups sends a message to one or more multicast groups. SendMessageToGroups(groups []nodeconfig.GroupID, msg []byte) error PubSub() *libp2p_pubsub.PubSub C() (int, int, int) GetOrJoin(topic string) (*libp2p_pubsub.Topic, error) ListPeer(topic string) []libp2p_peer.ID ListTopic() []string ListBlockedPeer() []libp2p_peer.ID }
Host is the client + server in p2p network.
type HostConfig ¶
type HostConfig struct { Self *Peer BLSKey libp2p_crypto.PrivKey BootNodes []string DataStoreFile *string }
HostConfig is the config structure to create a new host
type HostV2 ¶
type HostV2 struct {
// contains filtered or unexported fields
}
HostV2 is the version 2 p2p host
func (*HostV2) AddStreamProtocol ¶
AddStreamProtocol adds the stream protocols to the host to be started and closed when the host starts or close
func (*HostV2) ConnectHostPeer ¶
ConnectHostPeer connects to peer host
func (*HostV2) GetDiscovery ¶
GetDiscovery returns the underlying discovery
func (*HostV2) GetOrJoin ¶
func (host *HostV2) GetOrJoin(topic string) (*libp2p_pubsub.Topic, error)
GetOrJoin ..
func (*HostV2) GetP2PHost ¶
func (host *HostV2) GetP2PHost() libp2p_host.Host
GetP2PHost returns the p2p.Host
func (*HostV2) ListBlockedPeer ¶
func (host *HostV2) ListBlockedPeer() []libp2p_peer.ID
ListBlockedPeer returns list of blocked peer
func (*HostV2) ListPeer ¶
func (host *HostV2) ListPeer(topic string) []libp2p_peer.ID
ListPeer returns list of peers in a topic
func (*HostV2) Peerstore ¶
func (host *HostV2) Peerstore() libp2p_peerstore.Peerstore
Peerstore returns the peer store
func (*HostV2) SendMessageToGroups ¶
func (host *HostV2) SendMessageToGroups(groups []nodeconfig.GroupID, msg []byte) (err error)
SendMessageToGroups sends a message to one or more multicast groups. It returns a nil error if and only if it has succeeded to schedule the given message for sending.
type NamedTopic ¶
type NamedTopic struct { Name string Topic *libp2p_pubsub.Topic }
NamedTopic represents pubsub topic Name is the human readable topic, groupID
type Peer ¶
type Peer struct { IP string // IP address of the peer Port string // Port number of the peer ConsensusPubKey *bls.PublicKey // Public key of the peer, used for consensus signing Addrs []ma.Multiaddr // MultiAddress of the peer PeerID libp2p_peer.ID // PeerID, the pubkey for communication }
Peer is the object for a p2p peer (node)