mirror of
https://github.com/ayflying/p2p.git
synced 2026-03-05 09:49:22 +00:00
修复依赖
This commit is contained in:
@@ -34,7 +34,7 @@ type Client struct {
|
||||
|
||||
func (s *sP2P) Start(ctx context.Context, wsStr string) (err error) {
|
||||
|
||||
hostObj, err := s.createLibp2pHost(ctx, 0)
|
||||
hostObj, err := s.CreateLibp2pHost(ctx, 0)
|
||||
if err != nil {
|
||||
g.Log().Error(ctx, err)
|
||||
}
|
||||
@@ -70,7 +70,7 @@ func (s *sP2P) Start(ctx context.Context, wsStr string) (err error) {
|
||||
}
|
||||
|
||||
// 创建libp2p主机
|
||||
func (s *sP2P) createLibp2pHost(ctx context.Context, port int) (host.Host, error) {
|
||||
func (s *sP2P) CreateLibp2pHost(ctx context.Context, port int) (host.Host, error) {
|
||||
if port == 0 {
|
||||
//port = grand.N(50000, 55000)
|
||||
port = 53533
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
// 初始化无服务器DHT(作为节点加入DHT网络)
|
||||
func (s *sP2P) InitDHT(ctx context.Context, h host.Host) (*dht.IpfsDHT, error) {
|
||||
func (s *sP2P) DHTStart(ctx context.Context, h host.Host) (*dht.IpfsDHT, error) {
|
||||
// 创建DHT实例,设置为“客户端+服务端模式”(既可以查找数据,也可以存储数据)
|
||||
kdht, err := dht.New(ctx, h, dht.Mode(dht.ModeServer))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user