mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
38d2899fbb
Encapsulating the peer state was a win for lightningd; not surprisingly, it's even more of a win for the other daemons, especially as we want to add a little gossip information. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
37 lines
1.3 KiB
C
37 lines
1.3 KiB
C
#ifndef LIGHTNING_COMMON_PER_PEER_STATE_H
|
|
#define LIGHTNING_COMMON_PER_PEER_STATE_H
|
|
#include "config.h"
|
|
|
|
#include <ccan/tal/tal.h>
|
|
#include <common/crypto_state.h>
|
|
|
|
/* Things we hand between daemons to talk to peers. */
|
|
struct per_peer_state {
|
|
/* Cryptographic state needed to exchange messages with the peer (as
|
|
* featured in BOLT #8) */
|
|
struct crypto_state cs;
|
|
/* If not -1, closed on freeing */
|
|
int peer_fd, gossip_fd, gossip_store_fd;
|
|
};
|
|
|
|
/* Allocate a new per-peer state and add destructor to close fds if set;
|
|
* sets fds to -1. */
|
|
struct per_peer_state *new_per_peer_state(const tal_t *ctx,
|
|
const struct crypto_state *cs);
|
|
|
|
/* Initialize the fds (must be -1 previous) */
|
|
void per_peer_state_set_fds(struct per_peer_state *pps,
|
|
int peer_fd, int gossip_fd, int gossip_store_fd);
|
|
|
|
/* Array version of above: tal_count(fds) must be 3 */
|
|
void per_peer_state_set_fds_arr(struct per_peer_state *pps, const int *fds);
|
|
|
|
/* These routines do *part* of the work: you need to per_peer_state_fdpass_send
|
|
* or receive the three fds afterwards! */
|
|
void towire_per_peer_state(u8 **pptr, const struct per_peer_state *pps);
|
|
void per_peer_state_fdpass_send(int fd, const struct per_peer_state *pps);
|
|
|
|
struct per_peer_state *fromwire_per_peer_state(const tal_t *ctx,
|
|
const u8 **cursor, size_t *max);
|
|
#endif /* LIGHTNING_COMMON_PER_PEER_STATE_H */
|