mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
irc: Add contact information to nodes
The routing table now includes hostnames and ports for the node as well as a helper to add/update the nodes we learn about.
This commit is contained in:
parent
c97c47da47
commit
b2126375e0
@ -28,6 +28,7 @@ static bool node_eq(const struct node *n, const secp256k1_pubkey *key)
|
|||||||
{
|
{
|
||||||
return structeq(&n->id.pubkey, key);
|
return structeq(&n->id.pubkey, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
HTABLE_DEFINE_TYPE(struct node, keyof_node, hash_key, node_eq, node_map);
|
HTABLE_DEFINE_TYPE(struct node, keyof_node, hash_key, node_eq, node_map);
|
||||||
|
|
||||||
struct node_map *empty_node_map(struct lightningd_state *dstate)
|
struct node_map *empty_node_map(struct lightningd_state *dstate)
|
||||||
@ -69,6 +70,26 @@ struct node *new_node(struct lightningd_state *dstate,
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct node *add_node(
|
||||||
|
struct lightningd_state *dstate,
|
||||||
|
const struct pubkey *pk,
|
||||||
|
char *hostname,
|
||||||
|
int port)
|
||||||
|
{
|
||||||
|
struct node *n = get_node(dstate, pk);
|
||||||
|
if (!n) {
|
||||||
|
n = new_node(dstate, pk);
|
||||||
|
log_debug_struct(dstate->base_log, "Creating new node %s",
|
||||||
|
struct pubkey, pk);
|
||||||
|
} else {
|
||||||
|
log_debug_struct(dstate->base_log, "Update existing node %s",
|
||||||
|
struct pubkey, pk);
|
||||||
|
}
|
||||||
|
n->hostname = tal_steal(n, hostname);
|
||||||
|
n->port = port;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
static bool remove_conn_from_array(struct node_connection ***conns,
|
static bool remove_conn_from_array(struct node_connection ***conns,
|
||||||
struct node_connection *nc)
|
struct node_connection *nc)
|
||||||
{
|
{
|
||||||
|
@ -20,6 +20,11 @@ struct node_connection {
|
|||||||
|
|
||||||
struct node {
|
struct node {
|
||||||
struct pubkey id;
|
struct pubkey id;
|
||||||
|
|
||||||
|
/* IP/Hostname and port of this node */
|
||||||
|
char *hostname;
|
||||||
|
int port;
|
||||||
|
|
||||||
/* Routes connecting to us, from us. */
|
/* Routes connecting to us, from us. */
|
||||||
struct node_connection **in, **out;
|
struct node_connection **in, **out;
|
||||||
|
|
||||||
@ -46,6 +51,12 @@ struct node *get_node(struct lightningd_state *dstate,
|
|||||||
* If it returns more than msatoshi, it overflowed. */
|
* If it returns more than msatoshi, it overflowed. */
|
||||||
s64 connection_fee(const struct node_connection *c, u64 msatoshi);
|
s64 connection_fee(const struct node_connection *c, u64 msatoshi);
|
||||||
|
|
||||||
|
/* Updates existing node, or creates a new one as required. */
|
||||||
|
struct node *add_node(struct lightningd_state *dstate,
|
||||||
|
const struct pubkey *pk,
|
||||||
|
char *hostname,
|
||||||
|
int port);
|
||||||
|
|
||||||
/* Updates existing connection, or creates new one as required. */
|
/* Updates existing connection, or creates new one as required. */
|
||||||
struct node_connection *add_connection(struct lightningd_state *dstate,
|
struct node_connection *add_connection(struct lightningd_state *dstate,
|
||||||
const struct pubkey *from,
|
const struct pubkey *from,
|
||||||
|
Loading…
Reference in New Issue
Block a user