mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
paymod: Generate type-safe accessor functions for modifier data
This should make it easy for JSON-RPC functions and modifiers to get the associated data for a given modifier name. Useful if a modifier needs to access its parent's modifier data, or in other functions that need to access modifier data, e.g., when passing destination pointers into the `param()` call.
This commit is contained in:
@@ -146,6 +146,19 @@ void payment_continue(struct payment *p)
|
||||
abort();
|
||||
}
|
||||
|
||||
void *payment_mod_get_data(const struct payment *p,
|
||||
const struct payment_modifier *mod)
|
||||
{
|
||||
for (size_t i = 0; p->modifiers[i] != NULL; i++)
|
||||
if (p->modifiers[i] == mod)
|
||||
return p->modifier_data[i];
|
||||
|
||||
/* If we ever get here it means that we asked for the data for a
|
||||
* non-existent modifier. This is a compile-time/wiring issue, so we
|
||||
* better check that modifiers match the data we ask for. */
|
||||
abort();
|
||||
}
|
||||
|
||||
static inline struct dummy_data *
|
||||
dummy_data_init(struct payment *p)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user