2019-06-03 20:11:25 +02:00
|
|
|
#ifndef LIGHTNING_COMMON_PER_PEER_STATE_H
|
|
|
|
#define LIGHTNING_COMMON_PER_PEER_STATE_H
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <ccan/tal/tal.h>
|
2019-06-03 20:15:25 +02:00
|
|
|
#include <ccan/time/time.h>
|
2019-06-03 20:11:25 +02:00
|
|
|
#include <common/crypto_state.h>
|
|
|
|
|
2019-06-03 20:15:25 +02:00
|
|
|
struct gossip_state {
|
|
|
|
/* Time for next gossip burst. */
|
|
|
|
struct timemono next_gossip;
|
2019-06-03 20:19:25 +02:00
|
|
|
/* Timestamp filtering for gossip. */
|
|
|
|
u32 timestamp_min, timestamp_max;
|
2019-06-03 20:15:25 +02:00
|
|
|
};
|
|
|
|
|
2019-06-03 20:11:25 +02:00
|
|
|
/* Things we hand between daemons to talk to peers. */
|
|
|
|
struct per_peer_state {
|
|
|
|
/* If not -1, closed on freeing */
|
2022-01-08 14:29:29 +01:00
|
|
|
int peer_fd, gossip_fd;
|
2019-06-03 20:11:25 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Allocate a new per-peer state and add destructor to close fds if set;
|
2022-01-08 14:29:29 +01:00
|
|
|
* sets fds to -1. */
|
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
|
|
|
|
|
|
|
/* Initialize the fds (must be -1 previous) */
|
|
|
|
void per_peer_state_set_fds(struct per_peer_state *pps,
|
2022-01-08 14:29:29 +01:00
|
|
|
int peer_fd, int gossip_fd);
|
2019-06-03 20:11:25 +02:00
|
|
|
|
2022-01-08 14:29:29 +01:00
|
|
|
/* Array version of above: tal_count(fds) must be 2 */
|
2019-06-03 20:11:25 +02:00
|
|
|
void per_peer_state_set_fds_arr(struct per_peer_state *pps, const int *fds);
|
|
|
|
|
|
|
|
void per_peer_state_fdpass_send(int fd, const struct per_peer_state *pps);
|
|
|
|
|
|
|
|
#endif /* LIGHTNING_COMMON_PER_PEER_STATE_H */
|