MCPcopy Create free account
hub / github.com/DOSNetwork/core / Reply

Method Reply

p2p/server.go:354–368  ·  view source on GitHub ↗

Reply sends a reply to the specific node

(ctx context.Context, id []byte, nonce uint64, msg proto.Message)

Source from the content-addressed store, hash-verified

352
353// Reply sends a reply to the specific node
354func (n *server) Reply(ctx context.Context, id []byte, nonce uint64, msg proto.Message) (err error) {
355 opCtx, opCancel := context.WithTimeout(ctx, 15*time.Second)
356 defer opCancel()
357 req := NewP2pRequest(opCtx, replyReq, id, "", msg, nonce)
358 if err = req.sendReq(n.replying); err != nil {
359 err = &P2PError{err: errors.Errorf("Reply sendReq failed: %w", err), dest: req.addr, t: time.Now()}
360 n.logger.Error(err)
361 return
362 }
363 if _, err = req.waitForResult(); err != nil {
364 err = &P2PError{err: errors.Errorf("Reply waitForResult failed: %w", err), dest: req.addr, t: time.Now()}
365 n.logger.Error(err)
366 }
367 return
368}
369
370func (n *server) eventDispatch() {
371 var wg sync.WaitGroup

Callers

nothing calls this directly

Calls 4

NewP2pRequestFunction · 0.85
sendReqMethod · 0.80
waitForResultMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected