mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
More significant things have been folded. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
35 lines
808 B
C
35 lines
808 B
C
#include "config.h"
|
|
#include <ccan/read_write_all/read_write_all.h>
|
|
#include <common/cryptomsg.h>
|
|
#include <common/peer_failed.h>
|
|
#include <common/peer_io.h>
|
|
#include <common/per_peer_state.h>
|
|
#include <common/status.h>
|
|
#include <errno.h>
|
|
#include <inttypes.h>
|
|
#include <netinet/in.h>
|
|
#include <netinet/tcp.h>
|
|
#include <sys/socket.h>
|
|
#include <wire/wire.h>
|
|
#include <wire/wire_io.h>
|
|
#include <wire/wire_sync.h>
|
|
|
|
void peer_write(struct per_peer_state *pps, const void *msg TAKES)
|
|
{
|
|
status_peer_io(LOG_IO_OUT, NULL, msg);
|
|
|
|
if (!wire_sync_write(pps->peer_fd, msg))
|
|
peer_failed_connection_lost();
|
|
}
|
|
|
|
u8 *peer_read(const tal_t *ctx, struct per_peer_state *pps)
|
|
{
|
|
u8 *msg = wire_sync_read(ctx, pps->peer_fd);
|
|
if (!msg)
|
|
peer_failed_connection_lost();
|
|
|
|
status_peer_io(LOG_IO_IN, NULL, msg);
|
|
|
|
return msg;
|
|
}
|