Browse Source

Added possibility to configure max_concurrent_htlcs value for our channels. Eclaire has a default of 30 and I thought why not going with their value and while doing so make it configureable.

pull/2938/head
Rene Pickhardt 5 years ago
committed by Rusty Russell
parent
commit
8e7428da53
  1. 3
      lightningd/lightningd.h
  2. 8
      lightningd/opening_control.c
  3. 19
      lightningd/options.c

3
lightningd/lightningd.h

@ -42,6 +42,9 @@ struct config {
u32 fee_base; u32 fee_base;
u32 fee_per_satoshi; u32 fee_per_satoshi;
/* htlcs per channel */
u32 max_concurrent_htlcs;
/* How long between changing commit and sending COMMIT message. */ /* How long between changing commit and sending COMMIT message. */
u32 commit_time_ms; u32 commit_time_ms;

8
lightningd/opening_control.c

@ -835,13 +835,7 @@ static void channel_config(struct lightningd *ld,
*/ */
ours->to_self_delay = ld->config.locktime_blocks; ours->to_self_delay = ld->config.locktime_blocks;
/* BOLT #2: ours->max_accepted_htlcs = ld->config.max_concurrent_htlcs;
*
* The receiving node MUST fail the channel if:
*...
* - `max_accepted_htlcs` is greater than 483.
*/
ours->max_accepted_htlcs = 483;
/* This is filled in by lightning_openingd, for consistency. */ /* This is filled in by lightning_openingd, for consistency. */
ours->channel_reserve = AMOUNT_SAT(UINT64_MAX); ours->channel_reserve = AMOUNT_SAT(UINT64_MAX);

19
lightningd/options.c

@ -457,6 +457,9 @@ static const struct config testnet_config = {
/* We offer to pay 5 times 2-block fee */ /* We offer to pay 5 times 2-block fee */
.commitment_fee_percent = 500, .commitment_fee_percent = 500,
/* Testnet blockspace is free. */
.max_concurrent_htlcs = 483,
/* Be aggressive on testnet. */ /* Be aggressive on testnet. */
.cltv_expiry_delta = 6, .cltv_expiry_delta = 6,
.cltv_final = 10, .cltv_final = 10,
@ -513,6 +516,9 @@ static const struct config mainnet_config = {
/* We offer to pay 5 times 2-block fee */ /* We offer to pay 5 times 2-block fee */
.commitment_fee_percent = 500, .commitment_fee_percent = 500,
/* While up to 483 htlcs are possible we do 30 by default (as eclair does) to save blockspace */
.max_concurrent_htlcs = 30,
/* BOLT #2: /* BOLT #2:
* *
* 1. the `cltv_expiry_delta` for channels, `3R+2G+2S`: if in doubt, a * 1. the `cltv_expiry_delta` for channels, `3R+2G+2S`: if in doubt, a
@ -569,7 +575,15 @@ static void check_config(struct lightningd *ld)
fatal("Commitment fee invalid min-max %u-%u", fatal("Commitment fee invalid min-max %u-%u",
ld->config.commitment_fee_min_percent, ld->config.commitment_fee_min_percent,
ld->config.commitment_fee_max_percent); ld->config.commitment_fee_max_percent);
/* BOLT #2:
*
* The receiving node MUST fail the channel if:
*...
* - `max_accepted_htlcs` is greater than 483.
*/
if (ld->config.max_concurrent_htlcs < 1 || ld->config.max_concurrent_htlcs > 483)
fatal("--max-concurrent-htlcs value must be between 1 and 483 it is: %u",
ld->config.max_concurrent_htlcs);
if (ld->config.anchor_confirms == 0) if (ld->config.anchor_confirms == 0)
fatal("anchor-confirms must be greater than zero"); fatal("anchor-confirms must be greater than zero");
@ -928,6 +942,9 @@ static void register_opts(struct lightningd *ld)
opt_register_arg("--fee-per-satoshi", opt_set_u32, opt_show_u32, opt_register_arg("--fee-per-satoshi", opt_set_u32, opt_show_u32,
&ld->config.fee_per_satoshi, &ld->config.fee_per_satoshi,
"Microsatoshi fee for every satoshi in HTLC"); "Microsatoshi fee for every satoshi in HTLC");
opt_register_arg("--max-concurrent-htlcs", opt_set_u32, opt_show_u32,
&ld->config.max_concurrent_htlcs,
"Number of HTLCs one channel can handle concurrently. Should be between 1 and 483");
opt_register_arg("--min-capacity-sat", opt_set_u64, opt_show_u64, opt_register_arg("--min-capacity-sat", opt_set_u64, opt_show_u64,
&ld->config.min_capacity_sat, &ld->config.min_capacity_sat,
"Minimum capacity in satoshis for accepting channels"); "Minimum capacity in satoshis for accepting channels");

Loading…
Cancel
Save