mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-20 13:54:36 +01:00
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>
This commit is contained in:
parent
8d6281175d
commit
19c030ea1f
5 changed files with 9 additions and 7 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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…
Add table
Reference in a new issue