mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 18:11:28 +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>
36 lines
1.1 KiB
C
36 lines
1.1 KiB
C
/* FIXME: We should deprecate this in favor of BOLT7 address descriptor */
|
|
#ifndef LIGHTNING_LIGHTNINGD_NETADDR_H
|
|
#define LIGHTNING_LIGHTNINGD_NETADDR_H
|
|
#include "config.h"
|
|
#include <ccan/tal/tal.h>
|
|
#include <netinet/in.h>
|
|
#include <netinet/ip.h>
|
|
#include <sys/socket.h>
|
|
|
|
struct addrinfo;
|
|
|
|
/* This can be extended to support other protocols in future. */
|
|
struct netaddr {
|
|
int type; /* See socket(2): SOCK_STREAM currently */
|
|
int protocol; /* See socket(2): 0 currently */
|
|
socklen_t addrlen;
|
|
union {
|
|
struct sockaddr s;
|
|
struct sockaddr_in ipv4;
|
|
struct sockaddr_in6 ipv6;
|
|
} saddr;
|
|
};
|
|
|
|
/* Get the name for this netaddr. */
|
|
char *netaddr_name(const tal_t *ctx, const struct netaddr *a);
|
|
|
|
/* Create a addrinfo (as wanted by io_connect) for this address. */
|
|
void netaddr_to_addrinfo(struct addrinfo *ai, const struct netaddr *a);
|
|
|
|
bool netaddr_from_fd(int fd, int type, int protocol, struct netaddr *a);
|
|
|
|
bool netaddr_from_blob(const void *linear, size_t len, struct netaddr *a);
|
|
char *netaddr_to_hex(const tal_t *ctx, const struct netaddr *a);
|
|
|
|
#endif /* LIGHTNING_LIGHTNINGD_NETADDR_H */
|