mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
Breaking changes here. This improves the semantics of `ConfigOption` and `options::Value` drastically. We've been using `options::Value` for 2 purposes 1. To specify the type and default value of an option 2. Coummunicate how a user configured an option We fall here in the pit-fall of being poor at both purposes. I've edited the code to ensure - `options::Value` -> To read or specify the value of an option - `option::ValueType` -> To specify the type of an option **Configure an option** Let's create an string-typed option create an option named `"required-string-opt"` the developer has to use the following code. ```rust let option = ConfigOption::new("required-string", Value::OptString, "description"); ``` The semantics of `OptString` might falsely suggest that it is optional to specify the config. However, we use `OptString` to say we are not providing a default-value. After this commit we can use instead ```rust let option = ConfigOption::new_str_no_default("required-string", "description"); ``` For reading a configured value the `option::Value` is somewhat cumbersome. The old version of had 6 different types of value ```rust let value = plugin.option("required-string"); match value { String(s) => {}, // User has configured string value or default Integer(i) => {}, // User has configured int value or default Boolean(b) => {}, // User has configured bool value or default OptString => {}, // User has not configured value and no default OptInteger = {}, // User has not configured value and no default OptBOolean => {}, // User has not configured value and no default } ``` This has been changed to ```rust let value = plugin.option("required-string"); match value { Some(String(s)) => {}, Some(Integer(i)) => {}, Some(Boolean(b)) => {}, None => {}, } ``` |
||
---|---|---|
.. | ||
bkpr | ||
clnrest | ||
examples | ||
grpc-plugin | ||
renepay | ||
spender | ||
src | ||
test | ||
.gitignore | ||
autoclean.c | ||
bcli.c | ||
Cargo.toml | ||
chanbackup.c | ||
commando.c | ||
fetchinvoice.c | ||
funder.c | ||
funder_policy.c | ||
funder_policy.h | ||
keysend.c | ||
libplugin-pay.c | ||
libplugin-pay.h | ||
libplugin.c | ||
libplugin.h | ||
Makefile | ||
offers.c | ||
offers.h | ||
offers_inv_hook.c | ||
offers_inv_hook.h | ||
offers_invreq_hook.c | ||
offers_invreq_hook.h | ||
offers_offer.c | ||
offers_offer.h | ||
pay.c | ||
README.md | ||
sql.c | ||
topology.c | ||
txprepare.c |
Plugin Directory
Any file in this directory which is executable and whose name only consists of alphanumeric characters, space, '.', '-' or '_' will be automatically loaded when lightningd starts (unless suppressed with commandline options).