Documentation ¶
Index ¶
- func AddrToPeerInfo(multiAddr string) (*peer.AddrInfo, error)
- func Message(data []byte) *network_pb.Message
- type Config
- type ConnectCallback
- type MessageHandler
- type Network
- type Option
- type P2P
- func (p2p *P2P) AsyncSend(addr *peer.AddrInfo, msg *network_pb.Message) error
- func (p2p *P2P) Broadcast(ids []*peer.AddrInfo, msg *network_pb.Message) error
- func (p2p *P2P) Connect(addr *peer.AddrInfo) error
- func (p2p *P2P) Disconnect(addr *peer.AddrInfo) error
- func (p2p *P2P) GetRemotePubKey(id peer.ID) (crypto.PubKey, error)
- func (p2p *P2P) Send(addr *peer.AddrInfo, msg *network_pb.Message) (*network_pb.Message, error)
- func (p2p *P2P) SendWithStream(s network.Stream, msg *network_pb.Message) error
- func (p2p *P2P) SetConnectCallback(callback ConnectCallback)
- func (p2p *P2P) SetMessageHandler(handler MessageHandler)
- func (p2p *P2P) Start() error
- func (p2p *P2P) Stop() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddrToPeerInfo ¶
AddrToPeerInfo transfer addr to PeerInfo addr example: "/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64"
func Message ¶
func Message(data []byte) *network_pb.Message
Types ¶
type ConnectCallback ¶
type MessageHandler ¶
type Network ¶
type Network interface { // Start start the network service. Start() error // Stop stop the network service. Stop() error // Connect connects peer by ID. Connect(*peer.AddrInfo) error // Disconnect peer with id Disconnect(*peer.AddrInfo) error // SetConnectionCallback sets the callback after connecting SetConnectCallback(ConnectCallback) // SetMessageHandler sets message handler SetMessageHandler(MessageHandler) // AsyncSend sends message to peer with peer info. AsyncSend(*peer.AddrInfo, *network_pb.Message) error // Send message using existed stream SendWithStream(network.Stream, *network_pb.Message) error // Send sends message waiting response Send(*peer.AddrInfo, *network_pb.Message) (*network_pb.Message, error) // Broadcast message to all node Broadcast([]*peer.AddrInfo, *network_pb.Message) error // GetRemotePubKey gets remote public key GetRemotePubKey(id peer.ID) (crypto.PubKey, error) }
type Option ¶
type Option func(*Config)
func WithLocalAddr ¶
func WithLogger ¶
func WithLogger(logger logrus.FieldLogger) Option
func WithPrivateKey ¶
func WithProtocolID ¶
type P2P ¶
type P2P struct {
// contains filtered or unexported fields
}
func (*P2P) GetRemotePubKey ¶ added in v1.0.1
func (*P2P) Send ¶
func (p2p *P2P) Send(addr *peer.AddrInfo, msg *network_pb.Message) (*network_pb.Message, error)
func (*P2P) SendWithStream ¶
func (*P2P) SetConnectCallback ¶
func (p2p *P2P) SetConnectCallback(callback ConnectCallback)
func (*P2P) SetMessageHandler ¶
func (p2p *P2P) SetMessageHandler(handler MessageHandler)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.