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

Method SendTo

p2p/set.go:236–249  ·  view source on GitHub ↗

SendTo() sends a message to a specific peer based on their public key

(publicKey []byte, topic lib.Topic, msg proto.Message)

Source from the content-addressed store, hash-verified

234
235// SendTo() sends a message to a specific peer based on their public key
236func (ps *PeerSet) SendTo(publicKey []byte, topic lib.Topic, msg proto.Message) lib.ErrorI {
237 defer lib.TimeTrack(ps.logger, time.Now(), time.Second)
238 bz, err := lib.Marshal(msg)
239 if err != nil {
240 return err
241 }
242 unlock := rlockWithTrace("peerset", &ps.mux, ps.logger)
243 defer unlock()
244 peer, err := ps.get(publicKey)
245 if err != nil {
246 return err
247 }
248 return ps.send(peer, topic, bz)
249}
250
251// SendToPeers() sends a message to all peers
252func (ps *PeerSet) SendToPeers(topic lib.Topic, msg proto.Message, excludeKeys ...string) lib.ErrorI {

Callers 7

sendBlockRequestsMethod · 0.80
SendToReplicasMethod · 0.80
SendToProposerMethod · 0.80
RequestBlockMethod · 0.80
SendBlockMethod · 0.80
TestMultiSendRecFunction · 0.80

Calls 5

getMethod · 0.95
sendMethod · 0.95
TimeTrackFunction · 0.92
MarshalFunction · 0.92
rlockWithTraceFunction · 0.85

Tested by 1

TestMultiSendRecFunction · 0.64