mirror of
https://github.com/ayflying/p2p.git
synced 2026-03-05 09:49:22 +00:00
增加dht的去中心化储存
This commit is contained in:
@@ -18,7 +18,6 @@ import (
|
||||
"github.com/google/uuid"
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/libp2p/go-libp2p"
|
||||
"github.com/libp2p/go-libp2p/core/crypto"
|
||||
"github.com/libp2p/go-libp2p/core/host"
|
||||
"github.com/libp2p/go-libp2p/core/network"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
@@ -123,7 +122,8 @@ func (s *sP2P) CreateLibp2pHost(ctx context.Context, port int) (host.Host, error
|
||||
}
|
||||
|
||||
// 1. 生成密钥对并初始化节点(确保身份有效)
|
||||
s.privKey, _, _ = crypto.GenerateKeyPair(crypto.Ed25519, 0) // 推荐使用Ed25519
|
||||
//s.privKey, _, _ = crypto.GenerateKeyPair(crypto.Ed25519, 0) // 推荐使用Ed25519
|
||||
s.privKey, _ = s.generateFixedKey()
|
||||
|
||||
// 创建主机
|
||||
h, err := libp2p.New(
|
||||
|
||||
Reference in New Issue
Block a user