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

Function state_update_ok

lightningd/peer_htlcs.c:30–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28#endif
29
30static bool state_update_ok(struct channel *channel,
31 enum htlc_state oldstate, enum htlc_state newstate,
32 u64 htlc_id, const char *dir)
33{
34 enum htlc_state expected = oldstate + 1;
35
36 /* We never get told about RCVD_REMOVE_HTLC, so skip over that
37 * (we initialize in SENT_ADD_HTLC / RCVD_ADD_COMMIT, so those
38 * work). */
39 if (expected == RCVD_REMOVE_HTLC)
40 expected = RCVD_REMOVE_COMMIT;
41
42 if (newstate != expected) {
43 channel_internal_error(channel,
44 "HTLC %s %"PRIu64" invalid update %s->%s",
45 dir, htlc_id,
46 htlc_state_name(oldstate),
47 htlc_state_name(newstate));
48 return false;
49 }
50
51 log_debug(channel->log, "HTLC %s %"PRIu64" %s->%s",
52 dir, htlc_id,
53 htlc_state_name(oldstate), htlc_state_name(newstate));
54 return true;
55}
56
57static bool htlc_in_update_state(struct channel *channel,
58 struct htlc_in *hin,

Callers 2

htlc_in_update_stateFunction · 0.85
htlc_out_update_stateFunction · 0.85

Calls 2

channel_internal_errorFunction · 0.70
htlc_state_nameFunction · 0.50

Tested by

no test coverage detected