mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
gossipd: turn off lease offers if the rates are empty
If received lease rates are empty (all zeroes), turn them off
This commit is contained in:
parent
c934fe095b
commit
9e839b177c
@ -53,6 +53,7 @@ COMMON_SRC_NOGEN := \
|
||||
common/key_derive.c \
|
||||
common/keyset.c \
|
||||
common/gossmap.c \
|
||||
common/lease_rates.c \
|
||||
common/memleak.c \
|
||||
common/msg_queue.c \
|
||||
common/node_id.c \
|
||||
|
17
common/lease_rates.c
Normal file
17
common/lease_rates.c
Normal file
@ -0,0 +1,17 @@
|
||||
#include "config.h"
|
||||
#include <ccan/ccan/mem/mem.h>
|
||||
#include <common/lease_rates.h>
|
||||
#include <wire/peer_wire.h>
|
||||
|
||||
bool lease_rates_empty(struct lease_rates *rates)
|
||||
{
|
||||
if (!rates)
|
||||
return true;
|
||||
|
||||
/* FIXME: why can't i do memeqzero? */
|
||||
return rates->funding_weight == 0
|
||||
&& rates->channel_fee_max_base_msat == 0
|
||||
&& rates->channel_fee_max_proportional_thousandths == 0
|
||||
&& rates->lease_fee_base_sat == 0
|
||||
&& rates->lease_fee_basis == 0;
|
||||
}
|
9
common/lease_rates.h
Normal file
9
common/lease_rates.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef LIGHTNING_COMMON_LEASE_RATES_H
|
||||
#define LIGHTNING_COMMON_LEASE_RATES_H
|
||||
#include "config.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
struct lease_rates;
|
||||
|
||||
bool lease_rates_empty(struct lease_rates *rates);
|
||||
#endif /* LIGHTNING_COMMON_LEASE_RATES_H */
|
@ -48,6 +48,7 @@ GOSSIPD_COMMON_OBJS := \
|
||||
common/status_wiregen.o \
|
||||
common/gossip_rcvd_filter.o \
|
||||
common/key_derive.o \
|
||||
common/lease_rates.o \
|
||||
common/memleak.o \
|
||||
common/msg_queue.o \
|
||||
common/node_id.o \
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <common/daemon_conn.h>
|
||||
#include <common/ecdh_hsmd.h>
|
||||
#include <common/features.h>
|
||||
#include <common/lease_rates.h>
|
||||
#include <common/memleak.h>
|
||||
#include <common/ping.h>
|
||||
#include <common/pseudorand.h>
|
||||
@ -1418,8 +1419,11 @@ static struct io_plan *handle_new_lease_rates(struct io_conn *conn,
|
||||
if (!fromwire_gossipd_new_lease_rates(msg, rates))
|
||||
master_badmsg(WIRE_GOSSIPD_NEW_LEASE_RATES, msg);
|
||||
|
||||
tal_free(daemon->rates);
|
||||
daemon->rates = rates;
|
||||
daemon->rates = tal_free(daemon->rates);
|
||||
if (!lease_rates_empty(rates))
|
||||
daemon->rates = rates;
|
||||
else
|
||||
tal_free(rates);
|
||||
|
||||
/* Send the update over to the peer */
|
||||
maybe_send_own_node_announce(daemon, false);
|
||||
|
Loading…
Reference in New Issue
Block a user