discovery

package
v0.0.0-...-37f8b3f Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddrList

type AddrList []maddr.Multiaddr

AddrList 我们需要的新类型,用于编写自定义标志解析器

func (*AddrList) Set

func (al *AddrList) Set(value string) error

Set 设置地址值 参数 value 为地址字符串

func (*AddrList) String

func (al *AddrList) String() string

String 返回地址列表的字符串表示

type DHT

type DHT struct {
	OTPKey           string   // OTP密钥
	OTPInterval      int      // OTP间隔
	KeyLength        int      // 密钥长度
	RendezvousString string   // 会合点字符串
	BootstrapPeers   AddrList // 引导节点列表

	RefreshDiscoveryTime time.Duration // 刷新发现时间
	*dht.IpfsDHT                       // DHT实例
	// contains filtered or unexported fields
}

DHT DHT发现服务结构体

func NewDHT

func NewDHT(d ...dht.Option) *DHT

NewDHT 创建新的DHT发现服务 参数 d 为DHT选项

func (*DHT) FindClosePeers

func (d *DHT) FindClosePeers(ll log.StandardLogger, onlyStaticRelays bool, static ...string) func(ctx context.Context, numPeers int) <-chan peer.AddrInfo

FindClosePeers 查找附近的对等节点 参数 ll 为日志记录器,onlyStaticRelays 为是否仅使用静态中继,static 为静态中继列表

func (*DHT) Option

func (d *DHT) Option(ctx context.Context) func(c *libp2p.Config) error

Option 返回libp2p选项

func (*DHT) Rendezvous

func (d *DHT) Rendezvous() string

Rendezvous 返回会合点字符串

func (*DHT) Run

func (d *DHT) Run(c log.StandardLogger, ctx context.Context, host host.Host) error

Run 运行DHT发现服务 参数 c 为日志记录器,ctx 为上下文,host 为libp2p主机

type MDNS

type MDNS struct {
	DiscoveryServiceTag string // 发现服务标签
}

MDNS mDNS发现服务结构体

func (*MDNS) Option

func (d *MDNS) Option(ctx context.Context) func(c *libp2p.Config) error

Option 返回libp2p选项

func (*MDNS) Run

func (d *MDNS) Run(l log.StandardLogger, ctx context.Context, host host.Host) error

Run 运行mDNS发现服务 参数 l 为日志记录器,ctx 为上下文,host 为libp2p主机

type Ring

type Ring struct {
	Data   []string // 数据存储
	Length int      // 环形缓冲区长度
}

Ring 环形缓冲区结构体

func (*Ring) Add

func (r *Ring) Add(s string)

Add 向环形缓冲区添加元素 参数 s 为要添加的字符串

Jump to

Keyboard shortcuts

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