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

Function try_update_blockheight

lightningd/channel_control.c:139–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137}
138
139static void try_update_blockheight(struct lightningd *ld,
140 struct channel *channel)
141{
142 u32 blockheight = get_block_height(ld->topology);
143 u8 *msg;
144
145 /* We don't update the blockheight for non-leased chans */
146 if (channel->lease_expiry == 0)
147 return;
148
149 log_debug(channel->log, "attempting update blockheight %s",
150 fmt_channel_id(tmpctx, &channel->cid));
151
152 if (!topology_synced(ld->topology)) {
153 log_debug(channel->log, "chain not synced,"
154 " not updating blockheight");
155 return;
156 }
157
158 /* If they're offline, check that we're not too far behind anyway */
159 if (!channel->owner) {
160 if (channel->opener == REMOTE) {
161 u32 peer_height
162 = get_blockheight(channel->blockheight_states,
163 channel->opener, REMOTE);
164
165 /* Lease no longer active, we don't (really) care */
166 if (peer_height >= channel->lease_expiry)
167 return;
168
169 assert(peer_height + 1008 > peer_height);
170 if (peer_height + 1008 < blockheight)
171 channel_fail_permanent(channel,
172 REASON_PROTOCOL,
173 "Offline peer is too"
174 " far behind,"
175 " terminating leased"
176 " channel. Our current"
177 " %u, theirs %u",
178 blockheight,
179 peer_height);
180 }
181 return;
182 }
183
184 /* If we're not opened/locked in yet, don't send update */
185 if (!channel_state_can_add_htlc(channel->state))
186 return;
187
188 log_debug(ld->log, "update_blockheight: height = %u", blockheight);
189
190 msg = towire_channeld_blockheight(NULL, blockheight);
191 subd_send_msg(channel->owner, take(msg));
192}
193
194void notify_feerate_change(struct lightningd *ld)
195{

Callers 3

lockin_has_completedFunction · 0.85
peer_start_channeldFunction · 0.85
channel_notify_new_blockFunction · 0.85

Calls 7

topology_syncedFunction · 0.85
get_blockheightFunction · 0.85
get_block_heightFunction · 0.70
channel_fail_permanentFunction · 0.70
subd_send_msgFunction · 0.70
fmt_channel_idFunction · 0.50

Tested by

no test coverage detected