Browse Source

gossip: Annotate locally added channels with their capacity

We were adding channels without their capacity, and eventually annotated them
when we exchanged `channel_update`s. This worked as long as we weren't
considering the channel capacity, but would result in local-only channels to be
unusable once we start checking.
ppa-0.6.1
Christian Decker 7 years ago
parent
commit
8a34933c1a
  1. 3
      channeld/channel.c
  2. 1
      gossipd/gossip_wire.csv
  3. 11
      gossipd/routing.c
  4. 2
      gossipd/test/run-bench-find_route.c
  5. 2
      gossipd/test/run-find_route-specific.c
  6. 2
      gossipd/test/run-find_route.c

3
channeld/channel.c

@ -275,7 +275,8 @@ static void make_channel_local_active(struct peer *peer)
/* Tell gossipd about local channel. */
msg = towire_gossip_local_add_channel(NULL,
&peer->short_channel_ids[LOCAL],
&peer->node_ids[REMOTE]);
&peer->node_ids[REMOTE],
peer->channel->funding_msat / 1000);
wire_sync_write(GOSSIP_FD, take(msg));
/* Tell gossipd and the other side what parameters we expect should

1
gossipd/gossip_wire.csv

@ -121,6 +121,7 @@ gossip_send_gossip,,gossip,len*u8
gossip_local_add_channel,3017
gossip_local_add_channel,,short_channel_id,struct short_channel_id
gossip_local_add_channel,,remote_node_id,struct pubkey
gossip_local_add_channel,,satoshis,u64
gossip_local_channel_update,3026
gossip_local_channel_update,,short_channel_id,struct short_channel_id

Can't render this file because it has a wrong number of fields in line 6.

11
gossipd/routing.c

@ -1672,9 +1672,13 @@ void handle_local_add_channel(struct routing_state *rstate, const u8 *msg)
{
struct short_channel_id scid;
struct pubkey remote_node_id;
struct chan *chan;
u64 satoshis;
if (!fromwire_gossip_local_add_channel(msg, &scid, &remote_node_id)) {
status_broken("Unable to parse local_add_channel message: %s", tal_hex(msg, msg));
if (!fromwire_gossip_local_add_channel(msg, &scid, &remote_node_id,
&satoshis)) {
status_broken("Unable to parse local_add_channel message: %s",
tal_hex(msg, msg));
return;
}
@ -1688,5 +1692,6 @@ void handle_local_add_channel(struct routing_state *rstate, const u8 *msg)
type_to_string(tmpctx, struct short_channel_id, &scid));
/* Create new (unannounced) channel */
new_chan(rstate, &scid, &rstate->local_id, &remote_node_id);
chan = new_chan(rstate, &scid, &rstate->local_id, &remote_node_id);
chan->satoshis = satoshis;
}

2
gossipd/test/run-bench-find_route.c

@ -66,7 +66,7 @@ bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNE
bool fromwire_channel_update(const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u16 *flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, u64 *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED)
{ fprintf(stderr, "fromwire_channel_update called!\n"); abort(); }
/* Generated stub for fromwire_gossip_local_add_channel */
bool fromwire_gossip_local_add_channel(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *remote_node_id UNNEEDED)
bool fromwire_gossip_local_add_channel(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *remote_node_id UNNEEDED, u64 *satoshis UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_local_add_channel called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_channel_announcement */
bool fromwire_gossip_store_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED, u64 *satoshis UNNEEDED)

2
gossipd/test/run-find_route-specific.c

@ -30,7 +30,7 @@ bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNE
bool fromwire_channel_update(const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u16 *flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, u64 *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED)
{ fprintf(stderr, "fromwire_channel_update called!\n"); abort(); }
/* Generated stub for fromwire_gossip_local_add_channel */
bool fromwire_gossip_local_add_channel(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *remote_node_id UNNEEDED)
bool fromwire_gossip_local_add_channel(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *remote_node_id UNNEEDED, u64 *satoshis UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_local_add_channel called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_channel_announcement */
bool fromwire_gossip_store_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED, u64 *satoshis UNNEEDED)

2
gossipd/test/run-find_route.c

@ -28,7 +28,7 @@ bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNE
bool fromwire_channel_update(const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u16 *flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, u64 *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED)
{ fprintf(stderr, "fromwire_channel_update called!\n"); abort(); }
/* Generated stub for fromwire_gossip_local_add_channel */
bool fromwire_gossip_local_add_channel(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *remote_node_id UNNEEDED)
bool fromwire_gossip_local_add_channel(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *remote_node_id UNNEEDED, u64 *satoshis UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_local_add_channel called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_channel_announcement */
bool fromwire_gossip_store_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED, u64 *satoshis UNNEEDED)

Loading…
Cancel
Save