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

Function handle_blockheight

channeld/channeld.c:3454–3495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3452}
3453
3454static void handle_blockheight(struct peer *peer, const u8 *inmsg)
3455{
3456 u32 blockheight;
3457
3458 if (!fromwire_channeld_blockheight(inmsg, &blockheight))
3459 master_badmsg(WIRE_CHANNELD_BLOCKHEIGHT, inmsg);
3460
3461 /* Save it, so we know */
3462 peer->our_blockheight = blockheight;
3463 if (peer->channel->opener == LOCAL)
3464 start_commit_timer(peer);
3465 else {
3466 u32 peer_height = get_blockheight(peer->channel->blockheight_states,
3467 peer->channel->opener,
3468 REMOTE);
3469 /* BOLT- #2:
3470 * The node _not responsible_ for initiating the channel:
3471 * ...
3472 * - if last received `blockheight` is > 1008 behind
3473 * currently known blockheight:
3474 * - SHOULD fail he channel
3475 */
3476 assert(peer_height + 1008 > peer_height);
3477 if (peer_height + 1008 < blockheight)
3478 peer_failed_err(peer->pps, &peer->channel_id,
3479 "Peer is too far behind, terminating"
3480 " leased channel. Our current"
3481 " %u, theirs %u",
3482 blockheight, peer_height);
3483 /* We're behind them... what do. It's possible they're lying,
3484 * but if we're in a lease this is actually in our favor so
3485 * we log it but otherwise continue on unchanged */
3486 if (peer_height > blockheight
3487 && peer_height > blockheight + 100)
3488 status_unusual("Peer reporting we've fallen %u"
3489 " blocks behind. Our height %u,"
3490 " their height %u",
3491 peer_height - blockheight,
3492 blockheight, peer_height);
3493
3494 }
3495}
3496
3497static void handle_config_channel(struct peer *peer, const u8 *inmsg)
3498{

Callers 1

req_inFunction · 0.85

Calls 4

start_commit_timerFunction · 0.85
get_blockheightFunction · 0.85
peer_failed_errFunction · 0.85
master_badmsgFunction · 0.50

Tested by

no test coverage detected