mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-10 00:24:19 +01:00
renepay: make pay_plugin a tal object.
Avoids a gratuitous "ctx" field, and the simplified declaration is now understood by `make update-mocks`. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -45,6 +45,9 @@ void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id U
|
||||
/* Generated stub for towire_node_id */
|
||||
void towire_node_id(u8 **pptr UNNEEDED, const struct node_id *id UNNEEDED)
|
||||
{ fprintf(stderr, "towire_node_id called!\n"); abort(); }
|
||||
/* Generated stub for towire_s64 */
|
||||
void towire_s64(u8 **pptr UNNEEDED, s64 v UNNEEDED)
|
||||
{ fprintf(stderr, "towire_s64 called!\n"); abort(); }
|
||||
/* Generated stub for towire_secp256k1_ecdsa_signature */
|
||||
void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED,
|
||||
const secp256k1_ecdsa_signature *signature UNNEEDED)
|
||||
@@ -67,9 +70,6 @@ void towire_u32(u8 **pptr UNNEEDED, u32 v UNNEEDED)
|
||||
/* Generated stub for towire_u64 */
|
||||
void towire_u64(u8 **pptr UNNEEDED, u64 v UNNEEDED)
|
||||
{ fprintf(stderr, "towire_u64 called!\n"); abort(); }
|
||||
/* Generated stub for towire_s64 */
|
||||
void towire_s64(u8 **pptr UNNEEDED, s64 v UNNEEDED)
|
||||
{ fprintf(stderr, "towire_s64 called!\n"); abort(); }
|
||||
/* Generated stub for towire_u8 */
|
||||
void towire_u8(u8 **pptr UNNEEDED, u8 v UNNEEDED)
|
||||
{ fprintf(stderr, "towire_u8 called!\n"); abort(); }
|
||||
|
||||
@@ -87,9 +87,6 @@ u32 fromwire_u32(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
|
||||
/* Generated stub for fromwire_u64 */
|
||||
u64 fromwire_u64(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_u64 called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_s64 */
|
||||
s64 fromwire_s64(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_s64 called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_u8 */
|
||||
u8 fromwire_u8(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_u8 called!\n"); abort(); }
|
||||
@@ -187,9 +184,6 @@ void towire_u32(u8 **pptr UNNEEDED, u32 v UNNEEDED)
|
||||
/* Generated stub for towire_u64 */
|
||||
void towire_u64(u8 **pptr UNNEEDED, u64 v UNNEEDED)
|
||||
{ fprintf(stderr, "towire_u64 called!\n"); abort(); }
|
||||
/* Generated stub for towire_s64 */
|
||||
void towire_s64(u8 **pptr UNNEEDED, s64 v UNNEEDED)
|
||||
{ fprintf(stderr, "towire_s64 called!\n"); abort(); }
|
||||
/* Generated stub for towire_u8 */
|
||||
void towire_u8(u8 **pptr UNNEEDED, u8 v UNNEEDED)
|
||||
{ fprintf(stderr, "towire_u8 called!\n"); abort(); }
|
||||
|
||||
@@ -499,6 +499,10 @@ void json_add_num(struct json_stream *result UNNEEDED, const char *fieldname UNN
|
||||
void json_add_preimage(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED,
|
||||
const struct preimage *preimage UNNEEDED)
|
||||
{ fprintf(stderr, "json_add_preimage called!\n"); abort(); }
|
||||
/* Generated stub for json_add_s64 */
|
||||
void json_add_s64(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED,
|
||||
int64_t value UNNEEDED)
|
||||
{ fprintf(stderr, "json_add_s64 called!\n"); abort(); }
|
||||
/* Generated stub for json_add_secret */
|
||||
void json_add_secret(struct json_stream *response UNNEEDED,
|
||||
const char *fieldname UNNEEDED,
|
||||
@@ -544,10 +548,6 @@ void json_add_u32(struct json_stream *result UNNEEDED, const char *fieldname UNN
|
||||
void json_add_u64(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED,
|
||||
uint64_t value UNNEEDED)
|
||||
{ fprintf(stderr, "json_add_u64 called!\n"); abort(); }
|
||||
/* Generated stub for json_add_s64 */
|
||||
void json_add_s64(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED,
|
||||
int64_t value UNNEEDED)
|
||||
{ fprintf(stderr, "json_add_s64 called!\n"); abort(); }
|
||||
/* Generated stub for json_add_uncommitted_channel */
|
||||
void json_add_uncommitted_channel(struct json_stream *response UNNEEDED,
|
||||
const struct uncommitted_channel *uc UNNEEDED,
|
||||
@@ -798,12 +798,6 @@ struct command_result *param_u64(struct command *cmd UNNEEDED, const char *name
|
||||
const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
|
||||
uint64_t **num UNNEEDED)
|
||||
{ fprintf(stderr, "param_u64 called!\n"); abort(); }
|
||||
/* Generated stub for channel_state_normalish */
|
||||
bool channel_state_normalish(const struct channel *channel UNNEEDED)
|
||||
{ fprintf(stderr, "channel_state_normalish called!\n"); abort(); }
|
||||
/* Generated stub for channel_state_awaitish */
|
||||
bool channel_state_awaitish(const struct channel *channel UNNEEDED)
|
||||
{ fprintf(stderr, "channel_state_awaitish called!\n"); abort(); }
|
||||
/* Generated stub for peer_any_active_channel */
|
||||
struct channel *peer_any_active_channel(struct peer *peer UNNEEDED, bool *others UNNEEDED)
|
||||
{ fprintf(stderr, "peer_any_active_channel called!\n"); abort(); }
|
||||
|
||||
@@ -29,8 +29,7 @@
|
||||
#define MAX(a,b) ((a)>(b)? (a) : (b))
|
||||
#define MIN(a,b) ((a)<(b)? (a) : (b))
|
||||
|
||||
static struct pay_plugin the_pay_plugin;
|
||||
struct pay_plugin * const pay_plugin = &the_pay_plugin;
|
||||
struct pay_plugin *pay_plugin;
|
||||
|
||||
static void timer_kick(struct payment *payment);
|
||||
static struct command_result *try_paying(struct command *cmd,
|
||||
@@ -64,7 +63,7 @@ void amount_msat_reduce_(struct amount_msat *dst,
|
||||
#if DEVELOPER
|
||||
static void memleak_mark(struct plugin *p, struct htable *memtable)
|
||||
{
|
||||
memleak_scan_region(memtable, pay_plugin, sizeof(*pay_plugin));
|
||||
memleak_scan_obj(memtable, pay_plugin);
|
||||
memleak_scan_htable(memtable, &pay_plugin->chan_extra_map->raw);
|
||||
}
|
||||
#endif
|
||||
@@ -80,7 +79,7 @@ static const char *init(struct plugin *p,
|
||||
{
|
||||
size_t num_channel_updates_rejected;
|
||||
|
||||
pay_plugin->ctx = notleak_with_children(tal(p,tal_t));
|
||||
tal_steal(p, pay_plugin);
|
||||
pay_plugin->plugin = p;
|
||||
pay_plugin->last_time = 0;
|
||||
|
||||
@@ -98,13 +97,13 @@ static const char *init(struct plugin *p,
|
||||
|
||||
list_head_init(&pay_plugin->payments);
|
||||
|
||||
pay_plugin->chan_extra_map = tal(pay_plugin->ctx,struct chan_extra_map);
|
||||
pay_plugin->chan_extra_map = tal(pay_plugin,struct chan_extra_map);
|
||||
chan_extra_map_init(pay_plugin->chan_extra_map);
|
||||
|
||||
pay_plugin->payflow_map = tal(pay_plugin->ctx,struct payflow_map);
|
||||
pay_plugin->payflow_map = tal(pay_plugin,struct payflow_map);
|
||||
payflow_map_init(pay_plugin->payflow_map);
|
||||
|
||||
pay_plugin->gossmap = gossmap_load(pay_plugin->ctx,
|
||||
pay_plugin->gossmap = gossmap_load(pay_plugin,
|
||||
GOSSIP_STORE_FILENAME,
|
||||
&num_channel_updates_rejected);
|
||||
|
||||
@@ -445,7 +444,7 @@ sendpay_flows(struct command *cmd,
|
||||
/* Flow now owned by all_flows instead of req., in this way we
|
||||
* can control the destruction occurs before we remove temporary
|
||||
* channels from chan_extra_map. */
|
||||
tal_steal(pay_plugin->ctx,flows[i]);
|
||||
tal_steal(pay_plugin,flows[i]);
|
||||
|
||||
/* Let's keep record of this flow. */
|
||||
payflow_map_add(pay_plugin->payflow_map,flows[i]);
|
||||
@@ -1469,6 +1468,11 @@ static const struct plugin_notification notifications[] = {
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
setup_locale();
|
||||
|
||||
/* Most gets initialized in init(), but set debug options here. */
|
||||
pay_plugin = tal(NULL, struct pay_plugin);
|
||||
pay_plugin->debug_mcf = pay_plugin->debug_payflow = false;
|
||||
|
||||
plugin_main(
|
||||
argv,
|
||||
init,
|
||||
@@ -1487,7 +1491,5 @@ int main(int argc, char *argv[])
|
||||
flag_option, &pay_plugin->debug_payflow),
|
||||
NULL);
|
||||
|
||||
// TODO(eduardo): I think this is actually never executed
|
||||
tal_free(pay_plugin->ctx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -75,9 +75,6 @@ struct pay_plugin {
|
||||
bool debug_mcf;
|
||||
bool debug_payflow;
|
||||
|
||||
/* I'll allocate all global (controlled by pay_plugin) variables tied to
|
||||
* this tal_t. */
|
||||
tal_t *ctx;
|
||||
/* Pending flows have HTLCs (in-flight) liquidity
|
||||
* attached that is reflected in the uncertainty network.
|
||||
* When sendpay_fail or sendpay_success notifications arrive
|
||||
@@ -96,7 +93,7 @@ struct pay_plugin {
|
||||
};
|
||||
|
||||
/* Set in init */
|
||||
extern struct pay_plugin * const pay_plugin;
|
||||
extern struct pay_plugin *pay_plugin;
|
||||
|
||||
/* Accumulate or panic on overflow */
|
||||
#define amount_msat_accumulate(dst, src) \
|
||||
|
||||
@@ -11,9 +11,6 @@
|
||||
|
||||
#include "../mcf.c"
|
||||
|
||||
/* update-mocks isn't quiet smart enough for this, so place here */
|
||||
struct pay_plugin *const pay_plugin;
|
||||
|
||||
/* AUTOGENERATED MOCKS START */
|
||||
/* Generated stub for flow_complete */
|
||||
void flow_complete(struct flow *flow UNNEEDED,
|
||||
@@ -43,6 +40,8 @@ s64 linear_fee_cost(
|
||||
double base_fee_penalty UNNEEDED,
|
||||
double delay_feefactor UNNEEDED)
|
||||
{ fprintf(stderr, "linear_fee_cost called!\n"); abort(); }
|
||||
/* Generated stub for pay_plugin */
|
||||
struct pay_plugin *pay_plugin;
|
||||
/* AUTOGENERATED MOCKS END */
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
||||
@@ -160,9 +160,6 @@ bool json_to_u32(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED, u32
|
||||
/* Generated stub for json_to_u64 */
|
||||
bool json_to_u64(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED, u64 *num UNNEEDED)
|
||||
{ fprintf(stderr, "json_to_u64 called!\n"); abort(); }
|
||||
/* Generated stub for json_to_s64 */
|
||||
bool json_to_s64(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED, s64 *num UNNEEDED)
|
||||
{ fprintf(stderr, "json_to_s64 called!\n"); abort(); }
|
||||
/* Generated stub for json_tok_bin_from_hex */
|
||||
u8 *json_tok_bin_from_hex(const tal_t *ctx UNNEEDED, const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED)
|
||||
{ fprintf(stderr, "json_tok_bin_from_hex called!\n"); abort(); }
|
||||
|
||||
@@ -309,6 +309,10 @@ void json_add_pubkey(struct json_stream *response UNNEEDED,
|
||||
void json_add_s32(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED,
|
||||
int32_t value UNNEEDED)
|
||||
{ fprintf(stderr, "json_add_s32 called!\n"); abort(); }
|
||||
/* Generated stub for json_add_s64 */
|
||||
void json_add_s64(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED,
|
||||
int64_t value UNNEEDED)
|
||||
{ fprintf(stderr, "json_add_s64 called!\n"); abort(); }
|
||||
/* Generated stub for json_add_secret */
|
||||
void json_add_secret(struct json_stream *response UNNEEDED,
|
||||
const char *fieldname UNNEEDED,
|
||||
@@ -354,10 +358,6 @@ void json_add_u32(struct json_stream *result UNNEEDED, const char *fieldname UNN
|
||||
void json_add_u64(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED,
|
||||
uint64_t value UNNEEDED)
|
||||
{ fprintf(stderr, "json_add_u64 called!\n"); abort(); }
|
||||
/* Generated stub for json_add_s64 */
|
||||
void json_add_s64(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED,
|
||||
int64_t value UNNEEDED)
|
||||
{ fprintf(stderr, "json_add_s64 called!\n"); abort(); }
|
||||
/* Generated stub for json_add_uncommitted_channel */
|
||||
void json_add_uncommitted_channel(struct json_stream *response UNNEEDED,
|
||||
const struct uncommitted_channel *uc UNNEEDED,
|
||||
|
||||
Reference in New Issue
Block a user