mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-09 07:10:16 +01:00
474887512d
Now the flow is much simpler from a lightningd POV: 1. If we want to connect to a peer, just send gossipd `gossipctl_reach_peer`. 2. Every new peer, gossipd hands up to lightningd, with global/local features and the peer fd and a gossip fd using `gossip_peer_connected` 3. If lightningd doesn't want it, it just hands the peerfd and global/local features back to gossipd using `gossipctl_handle_peer` 4. If a peer sends a non-gossip msg (eg `open_channel`) the gossipd sends it up using `gossip_peer_nongossip`. 5. If lightningd wants to fund a channel, it simply calls `release_channel`. Notes: * There's no more "unique_id": we use the peer id. * For the moment, we don't ask gossipd when we're told to list peers, so connected peers without a channel don't appear in the JSON getpeers API. * We add a `gossipctl_peer_addrhint` for the moment, so you can connect to a specific ip/port, but using other sources is a TODO. * We now (correctly) only give up on reaching a peer after we exchange init messages, which changes the test_disconnect case. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
121 lines
3.9 KiB
Plaintext
121 lines
3.9 KiB
Plaintext
#include <common/cryptomsg.h>
|
|
|
|
# Initialize the gossip daemon.
|
|
gossipctl_init,3000
|
|
gossipctl_init,,broadcast_interval,u32
|
|
gossipctl_init,,chain_hash,struct sha256_double
|
|
gossipctl_init,,id,struct pubkey
|
|
# If non-zero, port to listen on.
|
|
gossipctl_init,,port,u16
|
|
gossipctl_init,,gflen,u16
|
|
gossipctl_init,,gfeatures,gflen*u8
|
|
gossipctl_init,,lflen,u16
|
|
gossipctl_init,,lfeatures,lflen*u8
|
|
|
|
# Master -> gossipd: Optional hint for where to find peer.
|
|
gossipctl_peer_addrhint,3014
|
|
gossipctl_peer_addrhint,,id,struct pubkey
|
|
gossipctl_peer_addrhint,,addr,struct ipaddr
|
|
|
|
# Master -> gossipd: connect to a peer. We may get a peer_connected.
|
|
gossipctl_reach_peer,3001
|
|
gossipctl_reach_peer,,id,struct pubkey
|
|
|
|
# Gossipd -> master: we got a peer. Two fds: peer and gossip
|
|
gossip_peer_connected,3002
|
|
gossip_peer_connected,,id,struct pubkey
|
|
gossip_peer_connected,,crypto_state,struct crypto_state
|
|
gossip_peer_connected,,gflen,u16
|
|
gossip_peer_connected,,gfeatures,gflen*u8
|
|
gossip_peer_connected,,lflen,u16
|
|
gossip_peer_connected,,lfeatures,lflen*u8
|
|
|
|
# Gossipd -> master: peer sent non-gossip packet. Two fds: peer and gossip
|
|
gossip_peer_nongossip,3003
|
|
gossip_peer_nongossip,,id,struct pubkey
|
|
gossip_peer_nongossip,,crypto_state,struct crypto_state
|
|
gossip_peer_nongossip,,gflen,u16
|
|
gossip_peer_nongossip,,gfeatures,gflen*u8
|
|
gossip_peer_nongossip,,lflen,u16
|
|
gossip_peer_nongossip,,lfeatures,lflen*u8
|
|
gossip_peer_nongossip,,len,u16
|
|
gossip_peer_nongossip,,msg,len*u8
|
|
|
|
# Master -> gossipd: release a peer (so we can open a channel)
|
|
gossipctl_release_peer,3004
|
|
gossipctl_release_peer,,id,struct pubkey
|
|
|
|
# Gossipd -> master: reply to gossip_release_peer. Two fds: peer and gossip.
|
|
gossipctl_release_peer_reply,3104
|
|
gossipctl_release_peer_reply,,crypto_state,struct crypto_state
|
|
gossipctl_release_peer_reply,,gflen,u16
|
|
gossipctl_release_peer_reply,,gfeatures,gflen*u8
|
|
gossipctl_release_peer_reply,,lflen,u16
|
|
gossipctl_release_peer_reply,,lfeatures,lflen*u8
|
|
|
|
# Gossipd -> master: reply to gossip_release_peer if we couldn't find the peer.
|
|
gossipctl_release_peer_replyfail,3204
|
|
|
|
# Gossipd -> master: take over peer, with optional msg. (+peer fd)
|
|
gossipctl_handle_peer,3013
|
|
gossipctl_handle_peer,,id,struct pubkey
|
|
gossipctl_handle_peer,,crypto_state,struct crypto_state
|
|
gossipctl_handle_peer,,gflen,u16
|
|
gossipctl_handle_peer,,gfeatures,gflen*u8
|
|
gossipctl_handle_peer,,lflen,u16
|
|
gossipctl_handle_peer,,lfeatures,lflen*u8
|
|
gossipctl_handle_peer,,len,u16
|
|
gossipctl_handle_peer,,msg,len*u8
|
|
|
|
# Pass JSON-RPC getnodes call through
|
|
gossip_getnodes_request,3005
|
|
|
|
#include <lightningd/gossip_msg.h>
|
|
gossip_getnodes_reply,3105
|
|
gossip_getnodes_reply,,num_nodes,u16
|
|
gossip_getnodes_reply,,nodes,num_nodes*struct gossip_getnodes_entry
|
|
|
|
# Pass JSON-RPC getroute call through
|
|
gossip_getroute_request,3006
|
|
gossip_getroute_request,,source,struct pubkey
|
|
gossip_getroute_request,,destination,struct pubkey
|
|
gossip_getroute_request,,msatoshi,u32
|
|
gossip_getroute_request,,riskfactor,u16
|
|
|
|
gossip_getroute_reply,3106
|
|
gossip_getroute_reply,,num_hops,u16
|
|
gossip_getroute_reply,,hops,num_hops*struct route_hop
|
|
|
|
gossip_getchannels_request,3007
|
|
|
|
gossip_getchannels_reply,3107
|
|
gossip_getchannels_reply,,num_channels,u16
|
|
gossip_getchannels_reply,,nodes,num_channels*struct gossip_getchannels_entry
|
|
|
|
# Ping/pong test. Waits for a reply if it expects one.
|
|
gossip_ping,3008
|
|
gossip_ping,,id,struct pubkey
|
|
gossip_ping,,num_pong_bytes,u16
|
|
gossip_ping,,len,u16
|
|
|
|
gossip_ping_reply,3108
|
|
# False if id in gossip_ping was unknown.
|
|
gossip_ping_reply,,sent,bool
|
|
# 0 == no pong expected
|
|
gossip_ping_reply,,totlen,u16
|
|
|
|
# Given a short_channel_id, return the endpoints
|
|
gossip_resolve_channel_request,3009
|
|
gossip_resolve_channel_request,,channel_id,struct short_channel_id
|
|
|
|
gossip_resolve_channel_reply,3109
|
|
gossip_resolve_channel_reply,,num_keys,u16
|
|
gossip_resolve_channel_reply,,keys,num_keys*struct pubkey
|
|
|
|
# The main daemon forward some gossip message to gossipd, allows injecting
|
|
# arbitrary gossip messages.
|
|
gossip_forwarded_msg,3010
|
|
gossip_forwarded_msg,,msglen,u16
|
|
gossip_forwarded_msg,,msg,msglen*u8
|
|
|