MCPcopy Create free account
hub / github.com/ElementsProject/lightning / send_ping

Function send_ping

connectd/multiplex.c:564–584  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

562}
563
564static void send_ping(struct peer *peer)
565{
566 /* If it's still sending us traffic, maybe ping reply is backed up?
567 * That's OK, ping is just to make sure it's still alive, and clearly
568 * it is. */
569 if (time_before(peer->last_recv_time,
570 timeabs_sub(time_now(), time_from_sec(60)))) {
571 /* Already have a ping in flight? */
572 if (peer->expecting_pong != PONG_UNEXPECTED) {
573 status_peer_debug(&peer->id, "Last ping unreturned: hanging up");
574 if (peer->to_peer)
575 io_close(peer->to_peer);
576 return;
577 }
578
579 inject_peer_msg(peer, take(make_ping(NULL, 1, 0)));
580 peer->expecting_pong = PONG_EXPECTED_PROBING;
581 }
582
583 set_ping_timer(peer);
584}
585
586void send_custommsg(struct daemon *daemon, const u8 *msg)
587{

Callers

nothing calls this directly

Calls 8

time_beforeFunction · 0.85
timeabs_subFunction · 0.85
time_nowFunction · 0.85
time_from_secFunction · 0.85
io_closeFunction · 0.85
inject_peer_msgFunction · 0.85
make_pingFunction · 0.85
set_ping_timerFunction · 0.85

Tested by

no test coverage detected