mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 01:24:26 +01:00
gossip: cleanup keepalive updates to use the same create_channel_update() code.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
fca5a9ef30
commit
6454d7af84
@@ -1559,48 +1559,23 @@ fail:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void gossip_send_keepalive_update(struct routing_state *rstate,
|
static void gossip_send_keepalive_update(struct routing_state *rstate,
|
||||||
struct half_chan *hc)
|
const struct chan *chan,
|
||||||
|
const struct half_chan *hc)
|
||||||
{
|
{
|
||||||
secp256k1_ecdsa_signature sig;
|
u8 *update, *err;
|
||||||
struct bitcoin_blkid chain_hash;
|
|
||||||
struct short_channel_id scid;
|
|
||||||
u32 timestamp, fee_base_msat, fee_proportional_millionths;
|
|
||||||
u64 htlc_minimum_msat;
|
|
||||||
u16 flags, cltv_expiry_delta;
|
|
||||||
u8 *update, *msg, *err;
|
|
||||||
|
|
||||||
/* Parse old update */
|
/* Generate a new update, with up to date timestamp */
|
||||||
if (!fromwire_channel_update(
|
update = create_channel_update(tmpctx, rstate, chan,
|
||||||
hc->channel_update, &sig, &chain_hash, &scid, ×tamp,
|
hc->flags & ROUTING_FLAGS_DIRECTION,
|
||||||
&flags, &cltv_expiry_delta, &htlc_minimum_msat, &fee_base_msat,
|
false,
|
||||||
&fee_proportional_millionths)) {
|
hc->delay,
|
||||||
status_failed(
|
hc->htlc_minimum_msat,
|
||||||
STATUS_FAIL_INTERNAL_ERROR,
|
hc->base_fee,
|
||||||
"Unable to parse previously accepted channel_update");
|
hc->proportional_fee);
|
||||||
}
|
|
||||||
|
|
||||||
/* Now generate a new update, with up to date timestamp */
|
|
||||||
timestamp = time_now().ts.tv_sec;
|
|
||||||
update =
|
|
||||||
towire_channel_update(tmpctx, &sig, &chain_hash, &scid, timestamp,
|
|
||||||
flags, cltv_expiry_delta, htlc_minimum_msat,
|
|
||||||
fee_base_msat, fee_proportional_millionths);
|
|
||||||
|
|
||||||
if (!wire_sync_write(HSM_FD,
|
|
||||||
towire_hsm_cupdate_sig_req(tmpctx, update))) {
|
|
||||||
status_failed(STATUS_FAIL_HSM_IO, "Writing cupdate_sig_req: %s",
|
|
||||||
strerror(errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
msg = wire_sync_read(tmpctx, HSM_FD);
|
|
||||||
if (!msg || !fromwire_hsm_cupdate_sig_reply(tmpctx, msg, &update)) {
|
|
||||||
status_failed(STATUS_FAIL_HSM_IO,
|
|
||||||
"Reading cupdate_sig_req: %s",
|
|
||||||
strerror(errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
status_trace("Sending keepalive channel_update for %s",
|
status_trace("Sending keepalive channel_update for %s",
|
||||||
type_to_string(tmpctx, struct short_channel_id, &scid));
|
type_to_string(tmpctx, struct short_channel_id,
|
||||||
|
&chan->scid));
|
||||||
|
|
||||||
err = handle_channel_update(rstate, update, "keepalive");
|
err = handle_channel_update(rstate, update, "keepalive");
|
||||||
if (err)
|
if (err)
|
||||||
@@ -1645,7 +1620,8 @@ static void gossip_refresh_network(struct daemon *daemon)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
gossip_send_keepalive_update(daemon->rstate, hc);
|
gossip_send_keepalive_update(daemon->rstate, n->chans[i],
|
||||||
|
hc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user