paymod: Make payment_tree_result public to users can query state

This commit is contained in:
Christian Decker
2020-05-27 14:48:25 +02:00
parent fbd8cf1495
commit 7a266b8239
2 changed files with 19 additions and 18 deletions

View File

@@ -9,23 +9,6 @@
#define DEFAULT_FINAL_CLTV_DELTA 9 #define DEFAULT_FINAL_CLTV_DELTA 9
/* Just a container to collect a subtree result so we can summarize all
* sub-payments and return a reasonable result to the caller of `pay` */
struct payment_tree_result {
/* OR of all the leafs in the subtree. */
enum payment_step leafstates;
/* OR of all the inner nodes and leaf nodes. */
enum payment_step treestates;
struct amount_msat sent;
/* Preimage if any of the attempts succeeded. */
struct preimage *preimage;
u32 attempts;
};
struct payment *payment_new(tal_t *ctx, struct command *cmd, struct payment *payment_new(tal_t *ctx, struct command *cmd,
struct payment *parent, struct payment *parent,
struct payment_modifier **mods) struct payment_modifier **mods)
@@ -98,7 +81,7 @@ static struct command_result *payment_rpc_failure(struct command *cmd,
return command_still_pending(cmd); return command_still_pending(cmd);
} }
static struct payment_tree_result payment_collect_result(struct payment *p) struct payment_tree_result payment_collect_result(struct payment *p)
{ {
struct payment_tree_result res; struct payment_tree_result res;
size_t numchildren = tal_count(p->children); size_t numchildren = tal_count(p->children);

View File

@@ -122,6 +122,23 @@ enum payment_step {
PAYMENT_STEP_SUCCESS = 64, PAYMENT_STEP_SUCCESS = 64,
}; };
/* Just a container to collect a subtree result so we can summarize all
* sub-payments and return a reasonable result to the caller of `pay` */
struct payment_tree_result {
/* OR of all the leafs in the subtree. */
enum payment_step leafstates;
/* OR of all the inner nodes and leaf nodes. */
enum payment_step treestates;
struct amount_msat sent;
/* Preimage if any of the attempts succeeded. */
struct preimage *preimage;
u32 attempts;
};
struct payment { struct payment {
/* The command that triggered this payment. Only set for the root /* The command that triggered this payment. Only set for the root
* payment. */ * payment. */
@@ -260,5 +277,6 @@ struct payment *payment_new(tal_t *ctx, struct command *cmd,
void payment_start(struct payment *p); void payment_start(struct payment *p);
void payment_continue(struct payment *p); void payment_continue(struct payment *p);
struct payment *payment_root(struct payment *p); struct payment *payment_root(struct payment *p);
struct payment_tree_result payment_collect_result(struct payment *p);
#endif /* LIGHTNING_PLUGINS_LIBPLUGIN_PAY_H */ #endif /* LIGHTNING_PLUGINS_LIBPLUGIN_PAY_H */