Documentation
¶
Index ¶
- type BlankHost
- func (bh *BlankHost) Addrs() []ma.Multiaddr
- func (bh *BlankHost) Close() error
- func (bh *BlankHost) ConnManager() connmgr.ConnManager
- func (bh *BlankHost) Connect(ctx context.Context, ai peer.AddrInfo) error
- func (bh *BlankHost) EventBus() event.Bus
- func (bh *BlankHost) ID() peer.ID
- func (bh *BlankHost) Mux() protocol.Switch
- func (bh *BlankHost) Network() network.Network
- func (bh *BlankHost) NewStream(ctx context.Context, p peer.ID, protos ...protocol.ID) (network.Stream, error)
- func (bh *BlankHost) Peerstore() peerstore.Peerstore
- func (bh *BlankHost) RemoveStreamHandler(pid protocol.ID)
- func (bh *BlankHost) SetStreamHandler(pid protocol.ID, handler network.StreamHandler)
- func (bh *BlankHost) SetStreamHandlerMatch(pid protocol.ID, m func(protocol.ID) bool, handler network.StreamHandler)
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlankHost ¶
type BlankHost struct {
// contains filtered or unexported fields
}
BlankHost 是 host.Host 接口的最简实现
func NewBlankHost ¶
NewBlankHost 创建新的空白主机实例 参数:
- n: network.Network 网络实例
- options: ...Option 配置选项
返回:
- *BlankHost 空白主机实例
func (*BlankHost) ConnManager ¶
func (bh *BlankHost) ConnManager() connmgr.ConnManager
ConnManager 返回连接管理器 返回:
- connmgr.ConnManager 连接管理器
func (*BlankHost) Connect ¶
Connect 连接到指定的对等节点 参数:
- ctx: context.Context 上下文
- ai: peer.AddrInfo 对等节点信息
返回:
- error 错误信息
func (*BlankHost) NewStream ¶
func (bh *BlankHost) NewStream(ctx context.Context, p peer.ID, protos ...protocol.ID) (network.Stream, error)
NewStream 创建新的流 参数:
- ctx: context.Context 上下文
- p: peer.ID 对等节点ID
- protos: ...protocol.ID 协议ID列表
返回:
- network.Stream 网络流
- error 错误信息
func (*BlankHost) SetStreamHandler ¶
func (bh *BlankHost) SetStreamHandler(pid protocol.ID, handler network.StreamHandler)
SetStreamHandler 设置流处理器 参数:
- pid: protocol.ID 协议ID
- handler: network.StreamHandler 流处理器
func (*BlankHost) SetStreamHandlerMatch ¶
func (bh *BlankHost) SetStreamHandlerMatch(pid protocol.ID, m func(protocol.ID) bool, handler network.StreamHandler)
SetStreamHandlerMatch 设置带匹配函数的流处理器 参数:
- pid: protocol.ID 协议ID
- m: func(protocol.ID) bool 匹配函数
- handler: network.StreamHandler 流处理器
type Option ¶
type Option = func(cfg *config)
Option 定义配置选项函数类型
func WithConnectionManager ¶
func WithConnectionManager(cmgr connmgr.ConnManager) Option
WithConnectionManager 设置连接管理器选项 参数:
- cmgr: connmgr.ConnManager 连接管理器实例
返回:
- Option 配置选项函数
Click to show internal directories.
Click to hide internal directories.