core-lightning/common/read_peer_msg.c
Rusty Russell b968b18534 common: move is_peer_error/is_peer_warning from read_peer_msg.c to wire_error.c
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-23 15:48:50 +10:30

35 lines
756 B
C

#include "config.h"
#include <assert.h>
#include <bitcoin/chainparams.h>
#include <common/peer_failed.h>
#include <common/peer_io.h>
#include <common/per_peer_state.h>
#include <common/ping.h>
#include <common/read_peer_msg.h>
#include <common/status.h>
#include <common/wire_error.h>
#include <errno.h>
#include <wire/peer_wire.h>
#include <wire/wire_sync.h>
bool handle_peer_error_or_warning(struct per_peer_state *pps,
const u8 *msg TAKES)
{
const char *err;
err = is_peer_error(tmpctx, msg);
if (err)
peer_failed_received_errmsg(pps, true, err);
/* Simply log incoming warnings */
err = is_peer_warning(tmpctx, msg);
if (err) {
if (taken(msg))
tal_free(msg);
status_info("Received %s", err);
return true;
}
return false;
}