mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-15 20:09:18 +01:00
lease_rates: lease_rates_eq.
We don't actually use the NULL-is-equal in the one caller, so ignore that. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
87239dc691
commit
6da915c96a
2 changed files with 13 additions and 28 deletions
|
@ -7,36 +7,15 @@
|
|||
#include <common/lease_rates.h>
|
||||
#include <common/overflows.h>
|
||||
#include <common/type_to_string.h>
|
||||
#include <wire/peer_wire.h>
|
||||
|
||||
/* FIXME: Is there a better way to do this ? */
|
||||
bool lease_rates_eq(struct lease_rates *l1,
|
||||
struct lease_rates *l2)
|
||||
{
|
||||
if (!l1 != !l2)
|
||||
return false;
|
||||
|
||||
if (!l1)
|
||||
return true;
|
||||
|
||||
return l1->funding_weight == l2->funding_weight
|
||||
&& l1->channel_fee_max_base_msat == l2->channel_fee_max_base_msat
|
||||
&& l1->channel_fee_max_proportional_thousandths == l2->channel_fee_max_proportional_thousandths
|
||||
&& l1->lease_fee_base_sat == l2->lease_fee_base_sat
|
||||
&& l1->lease_fee_basis == l2->lease_fee_basis;
|
||||
}
|
||||
|
||||
bool lease_rates_empty(struct lease_rates *rates)
|
||||
bool lease_rates_empty(const struct lease_rates *rates)
|
||||
{
|
||||
/* static means it's zero initialized */
|
||||
static const struct lease_rates zero;
|
||||
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;
|
||||
return lease_rates_eq(rates, &zero);
|
||||
}
|
||||
|
||||
void lease_rates_get_commitment(struct pubkey *pubkey,
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define LIGHTNING_COMMON_LEASE_RATES_H
|
||||
#include "config.h"
|
||||
#include <stdbool.h>
|
||||
#include <wire/peer_wire.h>
|
||||
|
||||
struct amount_msat;
|
||||
struct amount_sat;
|
||||
|
@ -11,7 +12,7 @@ struct sha256;
|
|||
|
||||
#define LEASE_RATE_DURATION 4032
|
||||
|
||||
bool lease_rates_empty(struct lease_rates *rates);
|
||||
bool lease_rates_empty(const struct lease_rates *rates);
|
||||
|
||||
void lease_rates_get_commitment(struct pubkey *pubkey,
|
||||
u32 lease_expiry,
|
||||
|
@ -19,8 +20,13 @@ void lease_rates_get_commitment(struct pubkey *pubkey,
|
|||
u16 chan_fee_ppt,
|
||||
struct sha256 *sha);
|
||||
|
||||
bool lease_rates_eq(struct lease_rates *l1,
|
||||
struct lease_rates *l2);
|
||||
/* lease_rates_eq: has 2 padding bytes after third field */
|
||||
STRUCTEQ_DEF(lease_rates, 2,
|
||||
funding_weight,
|
||||
lease_fee_basis,
|
||||
channel_fee_max_proportional_thousandths,
|
||||
lease_fee_base_sat,
|
||||
channel_fee_max_base_msat);
|
||||
|
||||
bool lease_rates_calc_fee(struct lease_rates *rates,
|
||||
struct amount_sat accept_funding_sats,
|
||||
|
|
Loading…
Add table
Reference in a new issue