2021-02-01 03:58:50 +01:00
|
|
|
#include "config.h"
|
2019-06-03 20:11:25 +02:00
|
|
|
#include <assert.h>
|
|
|
|
#include <ccan/fdpass/fdpass.h>
|
2019-09-22 04:07:43 +02:00
|
|
|
#include <common/gossip_constants.h>
|
2019-06-03 20:11:25 +02:00
|
|
|
#include <common/per_peer_state.h>
|
|
|
|
#include <unistd.h>
|
2019-06-03 20:15:25 +02:00
|
|
|
#include <wire/wire.h>
|
2019-06-03 20:11:25 +02:00
|
|
|
|
2019-09-18 03:05:05 +02:00
|
|
|
bool dev_fast_gossip = false;
|
|
|
|
|
2019-06-03 20:11:25 +02:00
|
|
|
static void destroy_per_peer_state(struct per_peer_state *pps)
|
|
|
|
{
|
|
|
|
if (pps->peer_fd != -1)
|
|
|
|
close(pps->peer_fd);
|
|
|
|
}
|
|
|
|
|
2022-01-08 14:24:29 +01:00
|
|
|
struct per_peer_state *new_per_peer_state(const tal_t *ctx)
|
2019-06-03 20:11:25 +02:00
|
|
|
{
|
|
|
|
struct per_peer_state *pps = tal(ctx, struct per_peer_state);
|
|
|
|
|
2022-01-29 04:33:05 +01:00
|
|
|
pps->peer_fd = -1;
|
2019-06-03 20:11:25 +02:00
|
|
|
tal_add_destructor(pps, destroy_per_peer_state);
|
|
|
|
return pps;
|
|
|
|
}
|
|
|
|
|
2022-01-29 04:33:05 +01:00
|
|
|
void per_peer_state_set_fd(struct per_peer_state *pps, int peer_fd)
|
2019-06-03 20:11:25 +02:00
|
|
|
{
|
|
|
|
assert(pps->peer_fd == -1);
|
|
|
|
pps->peer_fd = peer_fd;
|
|
|
|
}
|
|
|
|
|
|
|
|
void per_peer_state_fdpass_send(int fd, const struct per_peer_state *pps)
|
|
|
|
{
|
|
|
|
assert(pps->peer_fd != -1);
|
|
|
|
fdpass_send(fd, pps->peer_fd);
|
|
|
|
}
|