MCPcopy
hub / github.com/canopy-network/canopy / send

Method send

p2p/set.go:294–303  ·  view source on GitHub ↗

send() sends a message to a specific peer object

(peer *Peer, topic lib.Topic, bz []byte)

Source from the content-addressed store, hash-verified

292
293// send() sends a message to a specific peer object
294func (ps *PeerSet) send(peer *Peer, topic lib.Topic, bz []byte) lib.ErrorI {
295 //ps.logger.Debugf("Sending %s message to %s", topic, lib.BytesToTruncatedString(peer.Address.PublicKey))
296 go func() {
297 ok := peer.conn.Send(topic, bz)
298 if !ok {
299 ps.logger.Errorf("sending %s message to %s failed", topic, lib.BytesToTruncatedString(peer.Address.PublicKey))
300 }
301 }()
302 return nil
303}
304
305// remove() decrements the in/out counters, and deletes it from the set
306func (ps *PeerSet) remove(peer *Peer) {

Callers 3

SendToRandPeerMethod · 0.95
SendToMethod · 0.95
SendToPeersMethod · 0.95

Calls 3

BytesToTruncatedStringFunction · 0.92
SendMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected