Documentation
¶
Index ¶
Constants ¶
View Source
const ( PingSize = 32 // PingSize 定义了 Ping 数据包的大小为 32 字节。 ID = "/dep2p/ping/1.0.0" // ID 定义了 Ping 服务的协议标识为 "/dep2p/ping/1.0.0"。 ServiceName = "dep2p.ping" // ServiceName 定义了 Ping 服务的名称为 "dep2p.ping"。 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type PingService ¶
PingService 是一个实现了 dep2p.ping 协议的服务
func NewPingService ¶
func NewPingService(h host.Host) *PingService
NewPingService 是创建 PingService 实例的函数 它接受一个 host.Host 参数 h,并返回一个指向 PingService 的指针
func (*PingService) Ping ¶
Ping 是 PingService 的 Ping 方法,用于向指定的对等节点发送 Ping 请求,并返回一个结果通道。 它接受一个上下文对象 ctx,用于控制 Ping 操作的取消或超时。 参数 p 是要 Ping 的对等节点的 peer.ID。 返回一个只读的结果通道,用于接收 Ping 操作的结果。
func (*PingService) PingHandler ¶
func (p *PingService) PingHandler(s network.Stream)
PingHandler 是 PingService 的 Ping 处理方法 它接受一个 network.Stream 参数 s,用于处理 Ping 请求
Click to show internal directories.
Click to hide internal directories.