MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / handlePeerDiscovery

Function handlePeerDiscovery

IceFireDB-SQLProxy/pkg/p2p/p2p.go:420–438  ·  view source on GitHub ↗

A function that connects the given host to all peers received from a channel of peer address information. Meant to be started as a go routine.

(nodehost host.Host, peerchan <-chan peer.AddrInfo)

Source from the content-addressed store, hash-verified

418// A function that connects the given host to all peers received from a
419// channel of peer address information. Meant to be started as a go routine.
420func handlePeerDiscovery(nodehost host.Host, peerchan <-chan peer.AddrInfo) {
421 // Iterate over the peer channel
422 for peer := range peerchan {
423 // Ignore if the discovered peer is the host itself
424 if peer.ID == nodehost.ID() {
425 continue
426 }
427
428 // Connect to the peer
429 err := nodehost.Connect(context.Background(), peer)
430
431 if err != nil {
432 logrus.Debugln("p2p peer connection failed: ", err)
433 }
434
435 logrus.Debugln("p2p peer connection success: ", peer.ID)
436 log.Println("p2p peer connection success: ", peer.ID)
437 }
438}
439
440// A function that generates a CID object for a given string and returns it.
441// Uses SHA256 to hash the string and generate a multihash from it.

Callers 2

AdvertiseConnectMethod · 0.70
AnnounceConnectMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected