mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +01:00
channel: receive gossip fd on exec.
This simplifies things a little: hand the fd on exec rather than over the request socket. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -32,9 +32,10 @@
|
|||||||
#include <wire/wire_io.h>
|
#include <wire/wire_io.h>
|
||||||
#include <wire/wire_sync.h>
|
#include <wire/wire_sync.h>
|
||||||
|
|
||||||
/* stdin == requests, 3 == peer */
|
/* stdin == requests, 3 == peer, 4 = gossip */
|
||||||
#define REQ_FD STDIN_FILENO
|
#define REQ_FD STDIN_FILENO
|
||||||
#define PEER_FD 3
|
#define PEER_FD 3
|
||||||
|
#define GOSSIP_FD 4
|
||||||
|
|
||||||
struct peer {
|
struct peer {
|
||||||
struct peer_crypto_state pcs;
|
struct peer_crypto_state pcs;
|
||||||
@@ -59,7 +60,6 @@ struct peer {
|
|||||||
|
|
||||||
struct msg_queue peer_out;
|
struct msg_queue peer_out;
|
||||||
|
|
||||||
int gossip_client_fd;
|
|
||||||
struct daemon_conn gossip_client;
|
struct daemon_conn gossip_client;
|
||||||
|
|
||||||
/* Announcement related information */
|
/* Announcement related information */
|
||||||
@@ -271,6 +271,10 @@ int main(int argc, char *argv[])
|
|||||||
| SECP256K1_CONTEXT_SIGN);
|
| SECP256K1_CONTEXT_SIGN);
|
||||||
status_setup(REQ_FD);
|
status_setup(REQ_FD);
|
||||||
msg_queue_init(&peer->peer_out, peer);
|
msg_queue_init(&peer->peer_out, peer);
|
||||||
|
|
||||||
|
daemon_conn_init(peer, &peer->gossip_client, GOSSIP_FD,
|
||||||
|
gossip_client_recv);
|
||||||
|
|
||||||
init_peer_crypto_state(peer, &peer->pcs);
|
init_peer_crypto_state(peer, &peer->pcs);
|
||||||
peer->funding_locked[LOCAL] = peer->funding_locked[REMOTE] = false;
|
peer->funding_locked[LOCAL] = peer->funding_locked[REMOTE] = false;
|
||||||
|
|
||||||
@@ -296,15 +300,6 @@ int main(int argc, char *argv[])
|
|||||||
status_failed(WIRE_CHANNEL_BAD_COMMAND, "%s",
|
status_failed(WIRE_CHANNEL_BAD_COMMAND, "%s",
|
||||||
tal_hex(msg, msg));
|
tal_hex(msg, msg));
|
||||||
tal_free(msg);
|
tal_free(msg);
|
||||||
peer->gossip_client_fd = fdpass_recv(REQ_FD);
|
|
||||||
|
|
||||||
daemon_conn_init(peer, &peer->gossip_client, peer->gossip_client_fd,
|
|
||||||
gossip_client_recv);
|
|
||||||
|
|
||||||
if (peer->gossip_client_fd == -1)
|
|
||||||
status_failed(
|
|
||||||
WIRE_CHANNEL_BAD_COMMAND,
|
|
||||||
"Did not receive a valid client socket to gossipd");
|
|
||||||
|
|
||||||
/* We derive everything from the one secret seed. */
|
/* We derive everything from the one secret seed. */
|
||||||
derive_basepoints(&seed, &peer->funding_pubkey[LOCAL], &points[LOCAL],
|
derive_basepoints(&seed, &peer->funding_pubkey[LOCAL], &points[LOCAL],
|
||||||
|
|||||||
@@ -648,7 +648,7 @@ static void peer_start_channeld(struct peer *peer, bool am_funder,
|
|||||||
"lightningd_channel", peer,
|
"lightningd_channel", peer,
|
||||||
channel_wire_type_name,
|
channel_wire_type_name,
|
||||||
update_channel_status, NULL,
|
update_channel_status, NULL,
|
||||||
peer->fd, -1);
|
peer->fd, peer->gossip_client_fd, -1);
|
||||||
if (!peer->owner) {
|
if (!peer->owner) {
|
||||||
log_unusual(peer->log, "Could not subdaemon channel: %s",
|
log_unusual(peer->log, "Could not subdaemon channel: %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
@@ -682,7 +682,6 @@ static void peer_start_channeld(struct peer *peer, bool am_funder,
|
|||||||
|
|
||||||
/* We don't expect a response: we are triggered by funding_depth_cb. */
|
/* We don't expect a response: we are triggered by funding_depth_cb. */
|
||||||
subd_send_msg(peer->owner, take(msg));
|
subd_send_msg(peer->owner, take(msg));
|
||||||
subd_send_fd(peer->owner, peer->gossip_client_fd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool opening_release_tx(struct subd *opening, const u8 *resp,
|
static bool opening_release_tx(struct subd *opening, const u8 *resp,
|
||||||
|
|||||||
Reference in New Issue
Block a user