Skip to content

Commit

Permalink
Merge branch 'CESSProject:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
jiuquxzy authored Apr 25, 2024
2 parents ca243c7 + 1c4eaa3 commit 12731ce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
19 changes: 5 additions & 14 deletions core/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,21 +341,12 @@ func NewPeerNode(ctx context.Context, cfg *config.Config) (*PeerNode, error) {
if err != nil {
return nil, err
}

peer_node.initProtocol(cfg.ProtocolPrefix)

for _, v := range boots {
bootstrapAddr, err := ma.NewMultiaddr(v)
if err != nil {
continue
}
peerinfo, err := peer.AddrInfoFromP2pAddr(bootstrapAddr)
if err != nil {
continue
}
peer_node.Connect(ctx, *peerinfo)
peer_node.OnlineAction(peerinfo.ID)
}
bootstrapAddr, _ := ma.NewMultiaddr(peer_node.bootnode)
peerinfo, _ := peer.AddrInfoFromP2pAddr(bootstrapAddr)
peer_node.OnlineAction(peerinfo.ID)
} else {
peer_node.OnlineProtocol = peer_node.NewOnlineProtocol()
}

return peer_node, nil
Expand Down
4 changes: 1 addition & 3 deletions examples/sub/sub.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"time"

p2pgo "github.com/CESSProject/p2p-go"
"github.com/CESSProject/p2p-go/config"
"github.com/CESSProject/p2p-go/core"
dht "github.com/libp2p/go-libp2p-kad-dht"
pubsub "github.com/libp2p/go-libp2p-pubsub"
Expand Down Expand Up @@ -52,7 +51,6 @@ func main() {
p2pgo.BootPeers([]string{
"_dnsaddr.boot-bucket-devnet.cess.cloud",
}),
p2pgo.ProtocolPrefix(config.TestnetProtocolPrefix),
)
if err != nil {
panic(err)
Expand Down Expand Up @@ -93,7 +91,7 @@ func main() {
if err != nil {
panic(err)
}

fmt.Println("join a room: ", room)
// subscribe to topic
subscriber, err := topic.Subscribe()
if err != nil {
Expand Down

0 comments on commit 12731ce

Please sign in to comment.