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:
Christian Decker
2016-09-28 16:52:03 +02:00
parent c97c47da47
commit b2126375e0
2 changed files with 32 additions and 0 deletions

View File

@@ -28,6 +28,7 @@ static bool node_eq(const struct node *n, const secp256k1_pubkey *key)
{
return structeq(&n->id.pubkey, key);
}
HTABLE_DEFINE_TYPE(struct node, keyof_node, hash_key, node_eq, node_map);
struct node_map *empty_node_map(struct lightningd_state *dstate)
@@ -69,6 +70,26 @@ struct node *new_node(struct lightningd_state *dstate,
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,
struct node_connection *nc)
{