mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-04 14:54:26 +01:00
common/read_peer_msg: remove.
Also means we simplify the handle_gossip_msg() since everyone wants it to use sync_crypto_write(). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
#include "config.h"
|
||||
#include <ccan/short_types/short_types.h>
|
||||
#include <ccan/tal/tal.h>
|
||||
#include <ccan/typesafe_cb/typesafe_cb.h>
|
||||
|
||||
struct crypto_state;
|
||||
struct channel_id;
|
||||
@@ -71,59 +70,8 @@ bool handle_peer_gossip_or_error(int peer_fd, int gossip_fd,
|
||||
const struct channel_id *channel_id,
|
||||
const u8 *msg TAKES);
|
||||
|
||||
/**
|
||||
* read_peer_msg - read & decode in a peer message, handling common ones.
|
||||
* @ctx: context to allocate return packet from.
|
||||
* @cs: the cryptostate (updated)
|
||||
* @chanid: the channel id (for identifying errors)
|
||||
* @send_reply: the way to send a reply packet (eg. sync_crypto_write_arg)
|
||||
*
|
||||
* This returns NULL if it handled the message, so it's normally called in
|
||||
* a loop.
|
||||
*/
|
||||
#define read_peer_msg(ctx, cs, chanid, send_reply, arg) \
|
||||
read_peer_msg_((ctx), PEER_FD, GOSSIP_FD, (cs), \
|
||||
(chanid), \
|
||||
typesafe_cb_preargs(void, void *, (send_reply), (arg), \
|
||||
struct crypto_state *, int, \
|
||||
const u8 *), \
|
||||
arg)
|
||||
|
||||
/* Like the above, but don't read from GOSSIP_FD */
|
||||
#define read_peer_msg_nogossip(ctx, cs, chanid, send_reply, arg) \
|
||||
read_peer_msg_((ctx), PEER_FD, -1, (cs), \
|
||||
(chanid), \
|
||||
typesafe_cb_preargs(void, void *, (send_reply), (arg), \
|
||||
struct crypto_state *, int, \
|
||||
const u8 *), \
|
||||
arg)
|
||||
|
||||
/* Helper: sync_crypto_write, with extra args it ignores */
|
||||
void sync_crypto_write_arg(struct crypto_state *cs, int fd, const u8 *TAKES,
|
||||
void *unused);
|
||||
|
||||
/* Handler for a gossip msg; used by channeld since it queues them. */
|
||||
#define handle_gossip_msg(msg, cs, send_reply, arg) \
|
||||
handle_gossip_msg_((msg), PEER_FD, (cs), \
|
||||
typesafe_cb_preargs(bool, void *, \
|
||||
(send_reply), (arg), \
|
||||
struct crypto_state *, int, \
|
||||
const u8 *), \
|
||||
arg)
|
||||
|
||||
void handle_gossip_msg_(const u8 *msg TAKES,
|
||||
int peer_fd,
|
||||
struct crypto_state *cs,
|
||||
void (*send_msg)(struct crypto_state *cs, int fd,
|
||||
const u8 *TAKES, void *arg),
|
||||
void *arg);
|
||||
|
||||
u8 *read_peer_msg_(const tal_t *ctx,
|
||||
int peer_fd, int gossip_fd,
|
||||
struct crypto_state *cs,
|
||||
const struct channel_id *channel,
|
||||
void (*send_reply)(struct crypto_state *cs, int fd,
|
||||
const u8 *TAKES, void *arg),
|
||||
void *arg);
|
||||
/* We got this message from gossipd: forward/quit as it asks. */
|
||||
void handle_gossip_msg(int peer_fd, struct crypto_state *cs,
|
||||
const u8 *msg TAKES);
|
||||
|
||||
#endif /* LIGHTNING_COMMON_READ_PEER_MSG_H */
|
||||
|
||||
Reference in New Issue
Block a user