Browse Source

moveonly: Move handle_local_add_channel to routing.h

Signed-off-by: Christian Decker <decker.christian@gmail.com>
ppa-0.6.1
Christian Decker 7 years ago
parent
commit
7497f972f1
  1. 49
      gossipd/gossip.c
  2. 50
      gossipd/routing.c
  3. 10
      gossipd/routing.h
  4. 3
      gossipd/test/run-bench-find_route.c
  5. 3
      gossipd/test/run-find_route-specific.c
  6. 3
      gossipd/test/run-find_route.c

49
gossipd/gossip.c

@ -786,55 +786,6 @@ static void handle_get_update(struct peer *peer, const u8 *msg)
daemon_conn_send(peer->remote, take(msg));
}
static void handle_local_add_channel(struct routing_state *rstate, u8 *msg)
{
struct short_channel_id scid;
struct bitcoin_blkid chain_hash;
struct pubkey remote_node_id;
u16 cltv_expiry_delta;
u32 fee_base_msat, fee_proportional_millionths;
u64 htlc_minimum_msat;
int idx;
struct chan *chan;
if (!fromwire_gossip_local_add_channel(
msg, &scid, &chain_hash, &remote_node_id,
&cltv_expiry_delta, &htlc_minimum_msat, &fee_base_msat,
&fee_proportional_millionths)) {
status_broken("Unable to parse local_add_channel message: %s", tal_hex(msg, msg));
return;
}
if (!structeq(&chain_hash, &rstate->chain_hash)) {
status_broken("Received local_add_channel for unknown chain %s",
type_to_string(msg, struct bitcoin_blkid,
&chain_hash));
return;
}
if (get_channel(rstate, &scid)) {
status_broken("Attempted to local_add_channel a known channel");
return;
}
/* Create new channel */
chan = new_chan(rstate, &scid, &rstate->local_id, &remote_node_id);
idx = pubkey_idx(&rstate->local_id, &remote_node_id),
/* Activate the half_chan from us to them. */
set_connection_values(chan, idx,
fee_base_msat,
fee_proportional_millionths,
cltv_expiry_delta,
true,
0,
htlc_minimum_msat);
/* Designed to match msg in handle_channel_update, for easy testing */
status_trace("Received local update for channel %s(%d) now ACTIVE",
type_to_string(msg, struct short_channel_id, &scid),
idx);
}
/**
* owner_msg_in - Called by the `peer->remote` upon receiving a
* message

50
gossipd/routing.c

@ -12,6 +12,7 @@
#include <common/type_to_string.h>
#include <common/wire_error.h>
#include <common/wireaddr.h>
#include <gossipd/gen_gossip_wire.h>
#include <inttypes.h>
#include <wire/gen_peer_wire.h>
@ -1488,3 +1489,52 @@ void route_prune(struct routing_state *rstate)
/* This frees all the chans and maybe even nodes. */
tal_free(pruned);
}
void handle_local_add_channel(struct routing_state *rstate, u8 *msg)
{
struct short_channel_id scid;
struct bitcoin_blkid chain_hash;
struct pubkey remote_node_id;
u16 cltv_expiry_delta;
u32 fee_base_msat, fee_proportional_millionths;
u64 htlc_minimum_msat;
int idx;
struct chan *chan;
if (!fromwire_gossip_local_add_channel(
msg, &scid, &chain_hash, &remote_node_id,
&cltv_expiry_delta, &htlc_minimum_msat, &fee_base_msat,
&fee_proportional_millionths)) {
status_broken("Unable to parse local_add_channel message: %s", tal_hex(msg, msg));
return;
}
if (!structeq(&chain_hash, &rstate->chain_hash)) {
status_broken("Received local_add_channel for unknown chain %s",
type_to_string(msg, struct bitcoin_blkid,
&chain_hash));
return;
}
if (get_channel(rstate, &scid)) {
status_broken("Attempted to local_add_channel a known channel");
return;
}
/* Create new channel */
chan = new_chan(rstate, &scid, &rstate->local_id, &remote_node_id);
idx = pubkey_idx(&rstate->local_id, &remote_node_id),
/* Activate the half_chan from us to them. */
set_connection_values(chan, idx,
fee_base_msat,
fee_proportional_millionths,
cltv_expiry_delta,
true,
0,
htlc_minimum_msat);
/* Designed to match msg in handle_channel_update, for easy testing */
status_trace("Received local update for channel %s(%d) now ACTIVE",
type_to_string(msg, struct short_channel_id, &scid),
idx);
}

10
gossipd/routing.h

@ -289,4 +289,14 @@ bool routing_add_channel_update(struct routing_state *rstate,
bool routing_add_node_announcement(struct routing_state *rstate,
const u8 *msg TAKES);
/**
* Add a local channel.
*
* Entrypoint to add a local channel that was not learned through gossip. This
* is the case for private channels or channels that have not yet reached
* `announce_depth`.
*/
void handle_local_add_channel(struct routing_state *rstate, u8 *msg);
#endif /* LIGHTNING_GOSSIPD_ROUTING_H */

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

@ -62,6 +62,9 @@ bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNE
/* Generated stub for fromwire_channel_update */
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 bitcoin_blkid *chain_hash UNNEEDED, struct pubkey *remote_node_id UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, u64 *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths 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)
{ fprintf(stderr, "fromwire_gossip_store_channel_announcement called!\n"); abort(); }

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

@ -26,6 +26,9 @@ bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNE
/* Generated stub for fromwire_channel_update */
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 bitcoin_blkid *chain_hash UNNEEDED, struct pubkey *remote_node_id UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, u64 *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths 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)
{ fprintf(stderr, "fromwire_gossip_store_channel_announcement called!\n"); abort(); }

3
gossipd/test/run-find_route.c

@ -24,6 +24,9 @@ bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNE
/* Generated stub for fromwire_channel_update */
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 bitcoin_blkid *chain_hash UNNEEDED, struct pubkey *remote_node_id UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, u64 *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths 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)
{ fprintf(stderr, "fromwire_gossip_store_channel_announcement called!\n"); abort(); }

Loading…
Cancel
Save