Browse Source

routing: Make routing_state aware of its own ID

This is used to identify our own announcements.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
ppa-0.6.1
Christian Decker 7 years ago
committed by Rusty Russell
parent
commit
19c030ea1f
  1. 2
      gossipd/gossip.c
  2. 4
      gossipd/routing.c
  3. 3
      gossipd/routing.h
  4. 3
      gossipd/test/run-find_route-specific.c
  5. 4
      gossipd/test/run-find_route.c

2
gossipd/gossip.c

@ -1114,7 +1114,7 @@ static struct io_plan *gossip_init(struct daemon_conn *master,
&daemon->localfeatures)) {
master_badmsg(WIRE_GOSSIPCTL_INIT, msg);
}
daemon->rstate = new_routing_state(daemon, &chain_hash);
daemon->rstate = new_routing_state(daemon, &chain_hash, &daemon->id);
setup_listeners(daemon, port);
return daemon_conn_read_next(master->conn, master);

4
gossipd/routing.c

@ -26,12 +26,14 @@ static struct node_map *empty_node_map(const tal_t *ctx)
}
struct routing_state *new_routing_state(const tal_t *ctx,
const struct sha256_double *chain_hash)
const struct sha256_double *chain_hash,
const struct pubkey *local_id)
{
struct routing_state *rstate = tal(ctx, struct routing_state);
rstate->nodes = empty_node_map(rstate);
rstate->broadcasts = new_broadcast_state(rstate);
rstate->chain_hash = *chain_hash;
rstate->local_id = *local_id;
return rstate;
}

3
gossipd/routing.h

@ -93,7 +93,8 @@ struct route_hop {
};
struct routing_state *new_routing_state(const tal_t *ctx,
const struct sha256_double *chain_hash);
const struct sha256_double *chain_hash,
const struct pubkey *local_id);
/* msatoshi must be possible (< 21 million BTC), ie < 2^60.
* If it returns more than msatoshi, it overflowed. */

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

@ -67,8 +67,6 @@ int main(void)
secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY
| SECP256K1_CONTEXT_SIGN);
rstate = new_routing_state(ctx, &zerohash);
pubkey_from_hexstr("03c173897878996287a8100469f954dd820fcd8941daed91c327f168f3329be0bf",
strlen("03c173897878996287a8100469f954dd820fcd8941daed91c327f168f3329be0bf"),
&a);
@ -79,6 +77,7 @@ int main(void)
strlen("02ea622d5c8d6143f15ed3ce1d501dd0d3d09d3b1c83a44d0034949f8a9ab60f06"),
&c);
rstate = new_routing_state(ctx, &zerohash, &a);
/* [{'active': True, 'short_id': '6990:2:1/1', 'fee_per_kw': 10, 'delay': 5, 'flags': 1, 'destination': '0230ad0e74ea03976b28fda587bb75bdd357a1938af4424156a18265167f5e40ae', 'source': '02ea622d5c8d6143f15ed3ce1d501dd0d3d09d3b1c83a44d0034949f8a9ab60f06', 'last_update': 1504064344}, */
nc = get_or_make_connection(rstate, &c, &b);

4
gossipd/test/run-find_route.c

@ -78,9 +78,9 @@ int main(void)
secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY
| SECP256K1_CONTEXT_SIGN);
rstate = new_routing_state(ctx, &zerohash);
memset(&tmp, 'a', sizeof(tmp));
rstate = new_routing_state(ctx, &zerohash, &a);
pubkey_from_privkey(&tmp, &a);
new_node(rstate, &a);

Loading…
Cancel
Save