mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-31 04:44:19 +01:00
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>
3.9 KiB
3.9 KiB
| 1 | #include <common/cryptomsg.h> |
|---|---|
| 2 | # Initialize the gossip daemon. |
| 3 | gossipctl_init,3000 |
| 4 | gossipctl_init,,broadcast_interval,u32 |
| 5 | gossipctl_init,,chain_hash,struct sha256_double |
| 6 | gossipctl_init,,id,struct pubkey |
| 7 | # If non-zero, port to listen on. |
| 8 | gossipctl_init,,port,u16 |
| 9 | gossipctl_init,,gflen,u16 |
| 10 | gossipctl_init,,gfeatures,gflen*u8 |
| 11 | gossipctl_init,,lflen,u16 |
| 12 | gossipctl_init,,lfeatures,lflen*u8 |
| 13 | # Master -> gossipd: Optional hint for where to find peer. |
| 14 | gossipctl_peer_addrhint,3014 |
| 15 | gossipctl_peer_addrhint,,id,struct pubkey |
| 16 | gossipctl_peer_addrhint,,addr,struct ipaddr |
| 17 | # Master -> gossipd: connect to a peer. We may get a peer_connected. |
| 18 | gossipctl_reach_peer,3001 |
| 19 | gossipctl_reach_peer,,id,struct pubkey |
| 20 | # Gossipd -> master: we got a peer. Two fds: peer and gossip |
| 21 | gossip_peer_connected,3002 |
| 22 | gossip_peer_connected,,id,struct pubkey |
| 23 | gossip_peer_connected,,crypto_state,struct crypto_state |
| 24 | gossip_peer_connected,,gflen,u16 |
| 25 | gossip_peer_connected,,gfeatures,gflen*u8 |
| 26 | gossip_peer_connected,,lflen,u16 |
| 27 | gossip_peer_connected,,lfeatures,lflen*u8 |
| 28 | # Gossipd -> master: peer sent non-gossip packet. Two fds: peer and gossip |
| 29 | gossip_peer_nongossip,3003 |
| 30 | gossip_peer_nongossip,,id,struct pubkey |
| 31 | gossip_peer_nongossip,,crypto_state,struct crypto_state |
| 32 | gossip_peer_nongossip,,gflen,u16 |
| 33 | gossip_peer_nongossip,,gfeatures,gflen*u8 |
| 34 | gossip_peer_nongossip,,lflen,u16 |
| 35 | gossip_peer_nongossip,,lfeatures,lflen*u8 |
| 36 | gossip_peer_nongossip,,len,u16 |
| 37 | gossip_peer_nongossip,,msg,len*u8 |
| 38 | # Master -> gossipd: release a peer (so we can open a channel) |
| 39 | gossipctl_release_peer,3004 |
| 40 | gossipctl_release_peer,,id,struct pubkey |
| 41 | # Gossipd -> master: reply to gossip_release_peer. Two fds: peer and gossip. |
| 42 | gossipctl_release_peer_reply,3104 |
| 43 | gossipctl_release_peer_reply,,crypto_state,struct crypto_state |
| 44 | gossipctl_release_peer_reply,,gflen,u16 |
| 45 | gossipctl_release_peer_reply,,gfeatures,gflen*u8 |
| 46 | gossipctl_release_peer_reply,,lflen,u16 |
| 47 | gossipctl_release_peer_reply,,lfeatures,lflen*u8 |
| 48 | # Gossipd -> master: reply to gossip_release_peer if we couldn't find the peer. |
| 49 | gossipctl_release_peer_replyfail,3204 |
| 50 | # Gossipd -> master: take over peer, with optional msg. (+peer fd) |
| 51 | gossipctl_handle_peer,3013 |
| 52 | gossipctl_handle_peer,,id,struct pubkey |
| 53 | gossipctl_handle_peer,,crypto_state,struct crypto_state |
| 54 | gossipctl_handle_peer,,gflen,u16 |
| 55 | gossipctl_handle_peer,,gfeatures,gflen*u8 |
| 56 | gossipctl_handle_peer,,lflen,u16 |
| 57 | gossipctl_handle_peer,,lfeatures,lflen*u8 |
| 58 | gossipctl_handle_peer,,len,u16 |
| 59 | gossipctl_handle_peer,,msg,len*u8 |
| 60 | # Pass JSON-RPC getnodes call through |
| 61 | gossip_getnodes_request,3005 |
| 62 | #include <lightningd/gossip_msg.h> |
| 63 | gossip_getnodes_reply,3105 |
| 64 | gossip_getnodes_reply,,num_nodes,u16 |
| 65 | gossip_getnodes_reply,,nodes,num_nodes*struct gossip_getnodes_entry |
| 66 | # Pass JSON-RPC getroute call through |
| 67 | gossip_getroute_request,3006 |
| 68 | gossip_getroute_request,,source,struct pubkey |
| 69 | gossip_getroute_request,,destination,struct pubkey |
| 70 | gossip_getroute_request,,msatoshi,u32 |
| 71 | gossip_getroute_request,,riskfactor,u16 |
| 72 | gossip_getroute_reply,3106 |
| 73 | gossip_getroute_reply,,num_hops,u16 |
| 74 | gossip_getroute_reply,,hops,num_hops*struct route_hop |
| 75 | gossip_getchannels_request,3007 |
| 76 | gossip_getchannels_reply,3107 |
| 77 | gossip_getchannels_reply,,num_channels,u16 |
| 78 | gossip_getchannels_reply,,nodes,num_channels*struct gossip_getchannels_entry |
| 79 | # Ping/pong test. Waits for a reply if it expects one. |
| 80 | gossip_ping,3008 |
| 81 | gossip_ping,,id,struct pubkey |
| 82 | gossip_ping,,num_pong_bytes,u16 |
| 83 | gossip_ping,,len,u16 |
| 84 | gossip_ping_reply,3108 |
| 85 | # False if id in gossip_ping was unknown. |
| 86 | gossip_ping_reply,,sent,bool |
| 87 | # 0 == no pong expected |
| 88 | gossip_ping_reply,,totlen,u16 |
| 89 | # Given a short_channel_id, return the endpoints |
| 90 | gossip_resolve_channel_request,3009 |
| 91 | gossip_resolve_channel_request,,channel_id,struct short_channel_id |
| 92 | gossip_resolve_channel_reply,3109 |
| 93 | gossip_resolve_channel_reply,,num_keys,u16 |
| 94 | gossip_resolve_channel_reply,,keys,num_keys*struct pubkey |
| 95 | # The main daemon forward some gossip message to gossipd, allows injecting |
| 96 | # arbitrary gossip messages. |
| 97 | gossip_forwarded_msg,3010 |
| 98 | gossip_forwarded_msg,,msglen,u16 |
| 99 | gossip_forwarded_msg,,msg,msglen*u8 |