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

Function state_update_ok

lightningd/peer_htlcs.c:27–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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