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

Function try_update_blockheight

lightningd/channel_control.c:63–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63static void try_update_blockheight(struct lightningd *ld,
64 struct channel *channel,
65 u32 blockheight)
66{
67 u8 *msg;
68
69 log_debug(channel->log, "attempting update blockheight %s",
70 type_to_string(tmpctx, struct channel_id, &channel->cid));
71
72 /* If they're offline, check that we're not too far behind anyway */
73 if (!channel->owner) {
74 if (channel->opener == REMOTE
75 && channel->lease_expiry > 0) {
76 u32 peer_height
77 = get_blockheight(channel->blockheight_states,
78 channel->opener, REMOTE);
79
80 /* Lease no longer active, we don't (really) care */
81 if (peer_height >= channel->lease_expiry)
82 return;
83
84 assert(peer_height + 1008 > peer_height);
85 if (peer_height + 1008 < blockheight)
86 channel_fail_permanent(channel,
87 REASON_PROTOCOL,
88 "Offline peer is too"
89 " far behind,"
90 " terminating leased"
91 " channel. Our current"
92 " %u, theirs %u",
93 blockheight,
94 peer_height);
95 }
96 return;
97 }
98
99 /* If we're not opened/locked in yet, don't send update */
100 if (!channel_fees_can_change(channel))
101 return;
102
103 /* We don't update the blockheight for non-leased chans */
104 if (channel->lease_expiry == 0)
105 return;
106
107 log_debug(ld->log, "update_blockheight: height = %u", blockheight);
108
109 msg = towire_channeld_blockheight(NULL, blockheight);
110 subd_send_msg(channel->owner, take(msg));
111}
112
113void notify_feerate_change(struct lightningd *ld)
114{

Callers 4

lockin_completeFunction · 0.85
peer_start_channeldFunction · 0.85
channel_tell_depthFunction · 0.85
channel_notify_new_blockFunction · 0.85

Calls 5

get_blockheightFunction · 0.85
channel_fees_can_changeFunction · 0.85
channel_fail_permanentFunction · 0.70
subd_send_msgFunction · 0.70
type_to_stringClass · 0.50

Tested by

no test coverage detected