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

Function handle_ping_done

lightningd/ping.c:33–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31}
32
33void handle_ping_done(struct subd *connectd, const u8 *msg)
34{
35 u16 totlen;
36 bool sent;
37 u64 reqid;
38 struct ping_command *ping_command;
39
40 if (!fromwire_connectd_ping_done(msg, &reqid, &sent, &totlen)) {
41 log_broken(connectd->log, "Malformed ping reply %s",
42 tal_hex(tmpctx, msg));
43 return;
44 }
45
46 ping_command = find_ping_command(connectd->ld, reqid);
47 if (!ping_command) {
48 log_broken(connectd->log, "ping reply for unknown reqid %"PRIu64, reqid);
49 return;
50 }
51
52 log_debug(connectd->log, "Got ping reply!");
53 if (!sent)
54 was_pending(command_fail(ping_command->cmd, LIGHTNINGD,
55 "Ping already pending"));
56 else {
57 struct json_stream *response = json_stream_success(ping_command->cmd);
58
59 json_add_num(response, "totlen", totlen);
60 was_pending(command_success(ping_command->cmd, response));
61 }
62}
63
64static struct command_result *json_ping(struct command *cmd,
65 const char *buffer,

Callers 1

connectd_msgFunction · 0.85

Calls 7

tal_hexFunction · 0.85
find_ping_commandFunction · 0.85
json_add_numFunction · 0.85
was_pendingFunction · 0.70
command_failFunction · 0.70
json_stream_successFunction · 0.70
command_successFunction · 0.70

Tested by

no test coverage detected