libp2p

package
v0.0.0-...-8cfcfd0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2022 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(cfg *config.Configure) (pbftnet.SwitcherI, error)

func PrivateKey2PeerID

func PrivateKey2PeerID(pri *ecdsa.PrivateKey) (string, error)

func PublicKey2PeerID

func PublicKey2PeerID(pub *ecdsa.PublicKey) (string, error)

func PublicString2PeerID

func PublicString2PeerID(key string) (string, error)

Types

type P2PNetWork

type P2PNetWork struct {
	Host host.Host

	sync.RWMutex
	// contains filtered or unexported fields
}

func (*P2PNetWork) Broadcast

func (p2p *P2PNetWork) Broadcast(modelID string, msg *pbftnet.BroadcastMsg) error

实现switcher接口 向所有的节点广播消息

func (*P2PNetWork) BroadcastExceptPeer

func (p2p *P2PNetWork) BroadcastExceptPeer(modelID string, msg *pbftnet.BroadcastMsg, p *pbftnet.Peer) error

BroadcastExceptPeer 除了某个节点 向任意节点广播消息

func (*P2PNetWork) BroadcastToPeer

func (p2p *P2PNetWork) BroadcastToPeer(modelID string, msg *pbftnet.BroadcastMsg, p *pbftnet.Peer) error

广播到指定的peer

func (*P2PNetWork) NodeDiscovery

func (p2p *P2PNetWork) NodeDiscovery()

func (*P2PNetWork) Peers

func (p2p *P2PNetWork) Peers() ([]*pbftnet.Peer, error)

func (*P2PNetWork) RegisterOnReceive

func (p2p *P2PNetWork) RegisterOnReceive(modelID string, callBack pbftnet.OnReceive) error

func (*P2PNetWork) RemovePeer

func (p2p *P2PNetWork) RemovePeer(p *pbftnet.Peer) error

移除某个peer

func (*P2PNetWork) SpecialNodeConnect

func (p2p *P2PNetWork) SpecialNodeConnect()

func (*P2PNetWork) Start

func (p2p *P2PNetWork) Start() error

type P2PStream

type P2PStream struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL