Documentation
¶
Index ¶
Constants ¶
View Source
const ( // ping 消息的大小(字节) PingSize = 32 // ping 协议标识符 ID = "/ipfs/ping/1.0.0" // ping 服务名称 ServiceName = "libp2p.ping" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type PingService ¶
PingService ping 服务结构体
func NewPingService ¶
func NewPingService(h host.Host) *PingService
NewPingService 创建一个新的 ping 服务 参数:
- h: host.Host libp2p 主机实例
返回值:
- *PingService ping 服务实例
func (*PingService) Ping ¶
Ping 向指定节点发送 ping 请求 参数:
- ctx: context.Context 上下文对象
- p: peer.ID 目标节点 ID
返回值:
- <-chan Result ping 结果通道
func (*PingService) PingHandler ¶
func (p *PingService) PingHandler(s network.Stream)
PingHandler 处理接收到的 ping 请求 参数:
- s: network.Stream 网络流对象
Click to show internal directories.
Click to hide internal directories.