gossip: Added scheleton for getroute calls

This includes the request/reply passed from the main daemon to
`gossipd` and the basic handlers.
This commit is contained in:
Christian Decker 2017-03-15 11:36:52 +01:00 committed by Rusty Russell
parent 23a1d7d475
commit 9273b615ab
3 changed files with 34 additions and 0 deletions

View File

@ -451,6 +451,12 @@ static struct io_plan *release_peer(struct io_conn *conn, struct daemon *daemon,
"Unknown peer %"PRIu64, unique_id);
}
static struct io_plan *getroute(struct io_conn *conn, struct daemon *daemon, u8 *msg)
{
return next_req_in(conn, daemon);
}
static struct io_plan *getnodes(struct io_conn *conn, struct daemon *daemon)
{
tal_t *tmpctx = tal_tmpctx(daemon);
@ -493,8 +499,12 @@ static struct io_plan *recv_req(struct io_conn *conn, struct daemon_conn *master
case WIRE_GOSSIP_GETNODES_REQUEST:
return getnodes(conn, daemon);
case WIRE_GOSSIP_GETROUTE_REQUEST:
return getroute(conn, daemon, daemon->msg_in);
case WIRE_GOSSIPCTL_RELEASE_PEER_REPLY:
case WIRE_GOSSIP_GETNODES_REPLY:
case WIRE_GOSSIP_GETROUTE_REPLY:
case WIRE_GOSSIPSTATUS_INIT_FAILED:
case WIRE_GOSSIPSTATUS_BAD_NEW_PEER_REQUEST:
case WIRE_GOSSIPSTATUS_BAD_RELEASE_REQUEST:

View File

@ -60,3 +60,14 @@ gossip_getnodes_request,5
gossip_getnodes_reply,105
gossip_getnodes_reply,0,num_nodes,u16
gossip_getnodes_reply,2,nodes,num_nodes*struct gossip_getnodes_entry
# Pass JSON-RPC getroute call through
gossip_getroute_request,6
gossip_getroute_request,0,source,struct pubkey
gossip_getroute_request,33,destination,struct pubkey
gossip_getroute_request,66,msatoshi,u32
gossip_getroute_request,70,riskfactor,u16
gossip_getroute_reply,106
gossip_getroute_reply,0,num_hops,u16
gossip_getroute_reply,2,hops,num_hops*struct route_hop

1 # These are fatal.
60 gossip_getroute_reply,2,hops,num_hops*struct route_hop
61
62
63
64
65
66
67
68
69
70
71
72
73

View File

@ -142,9 +142,11 @@ static size_t gossip_msg(struct subd *gossip, const u8 *msg, const int *fds)
case WIRE_GOSSIPCTL_NEW_PEER:
case WIRE_GOSSIPCTL_RELEASE_PEER:
case WIRE_GOSSIP_GETNODES_REQUEST:
case WIRE_GOSSIP_GETROUTE_REQUEST:
/* This is a reply, so never gets through to here. */
case WIRE_GOSSIPCTL_RELEASE_PEER_REPLY:
case WIRE_GOSSIP_GETNODES_REPLY:
case WIRE_GOSSIP_GETROUTE_REPLY:
break;
case WIRE_GOSSIPSTATUS_PEER_BAD_MSG:
peer_bad_message(gossip, msg);
@ -218,3 +220,14 @@ static const struct json_command getnodes_command = {
"getnodes", json_getnodes, "Retrieve all nodes in our local network view",
"Returns a list of all nodes that we know about"};
AUTODATA(json_command, &getnodes_command);
static void json_getroute(struct command *cmd, const char *buffer, const jsmntok_t *params)
{
}
static const struct json_command getroute_command = {
"getroute", json_getroute,
"Return route to {id} for {msatoshi}, using {riskfactor}",
"Returns a {route} array of {id} {msatoshi} {delay}: msatoshi and delay (in blocks) is cumulative."
};
AUTODATA(json_command, &getroute_command);