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

Function try_update_blockheight

lightningd/channel_control.c:145–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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