refactor: Moving functionality out of p2p_announce

Further decoupling the old daemons from the new daemons.
This commit is contained in:
Christian Decker
2017-01-22 16:16:51 +01:00
committed by Rusty Russell
parent 2c06524165
commit 2a7e757053
4 changed files with 37 additions and 29 deletions

View File

@@ -670,3 +670,29 @@ static const struct json_command getnodes_command = {
"Returns a 'nodes' array"
};
AUTODATA(json_command, &getnodes_command);
bool add_channel_direction(struct routing_state *rstate,
const struct pubkey *from,
const struct pubkey *to,
const int direction,
const struct channel_id *channel_id,
const u8 *announcement)
{
struct node_connection *c = get_connection(rstate, from, to);
if (c){
/* Do not clobber connections added otherwise */
memcpy(&c->channel_id, channel_id, sizeof(c->channel_id));
c->flags = direction;
return false;
}else if(get_connection_by_cid(rstate, channel_id, direction)) {
return false;
}
c = half_add_connection(rstate, from, to, channel_id, direction);
/* Remember the announcement so we can forward it to new peers */
tal_free(c->channel_announcement);
c->channel_announcement = tal_dup_arr(c, u8, announcement,
tal_count(announcement), 0);
return true;
}