iotex-core: Index | Files | Directories

package p2p

import ""


Package Files

agent.go context.go

func WitContext Uses

func WitContext(ctx context.Context, p2pCtx Context) context.Context

WitContext add Agent context into context.

type Agent Uses

type Agent struct {
    // contains filtered or unexported fields

Agent is the agent to help the blockchain node connect into the P2P networks and send/receive messages

func NewAgent Uses

func NewAgent(cfg config.Config, broadcastHandler HandleBroadcastInbound, unicastHandler HandleUnicastInboundAsync) *Agent

NewAgent instantiates a local P2P agent instance

func (*Agent) BroadcastOutbound Uses

func (p *Agent) BroadcastOutbound(ctx context.Context, msg proto.Message) (err error)

BroadcastOutbound sends a broadcast message to the whole network

func (*Agent) Info Uses

func (p *Agent) Info() peerstore.PeerInfo

Info returns agents' peer info.

func (*Agent) Neighbors Uses

func (p *Agent) Neighbors(ctx context.Context) ([]peerstore.PeerInfo, error)

Neighbors returns the neighbors' peer info

func (*Agent) Self Uses

func (p *Agent) Self() []multiaddr.Multiaddr

Self returns the self network address

func (*Agent) Start Uses

func (p *Agent) Start(ctx context.Context) error

Start connects into P2P network

func (*Agent) Stop Uses

func (p *Agent) Stop(ctx context.Context) error

Stop disconnects from P2P network

func (*Agent) UnicastOutbound Uses

func (p *Agent) UnicastOutbound(ctx context.Context, peer peerstore.PeerInfo, msg proto.Message) (err error)

UnicastOutbound sends a unicast message to the given address

type Context Uses

type Context struct {
    ChainID uint32

Context provides the auxiliary information Agent network operations

func GetContext Uses

func GetContext(ctx context.Context) (Context, bool)

GetContext gets Agent context

type HandleBroadcastInbound Uses

type HandleBroadcastInbound func(context.Context, uint32, proto.Message)

HandleBroadcastInbound handles broadcast message when agent listens it from the network

type HandleUnicastInboundAsync Uses

type HandleUnicastInboundAsync func(context.Context, uint32, peerstore.PeerInfo, proto.Message)

HandleUnicastInboundAsync handles unicast message when agent listens it from the network



Package p2p imports 21 packages (graph) and is imported by 2 packages. Updated 2019-12-06. Refresh now. Tools for package owners.