mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
plugins/topology: use memleak annotation instead of global_gossmap hammer.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
a0d531d515
commit
127539a993
@@ -684,6 +684,14 @@ done:
|
|||||||
return command_finished(cmd, js);
|
return command_finished(cmd, js);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if DEVELOPER
|
||||||
|
static void memleak_mark(struct plugin *p, struct htable *memtable)
|
||||||
|
{
|
||||||
|
memleak_remove_region(memtable, global_gossmap,
|
||||||
|
tal_bytelen(global_gossmap));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static const char *init(struct plugin *p,
|
static const char *init(struct plugin *p,
|
||||||
const char *buf UNUSED, const jsmntok_t *config UNUSED)
|
const char *buf UNUSED, const jsmntok_t *config UNUSED)
|
||||||
{
|
{
|
||||||
@@ -694,9 +702,9 @@ static const char *init(struct plugin *p,
|
|||||||
take(json_out_obj(NULL, NULL, NULL)),
|
take(json_out_obj(NULL, NULL, NULL)),
|
||||||
"{id:%}", JSON_SCAN(json_to_node_id, &local_id));
|
"{id:%}", JSON_SCAN(json_to_node_id, &local_id));
|
||||||
|
|
||||||
global_gossmap = notleak_with_children(gossmap_load(NULL,
|
global_gossmap = gossmap_load(NULL,
|
||||||
GOSSIP_STORE_FILENAME,
|
GOSSIP_STORE_FILENAME,
|
||||||
&num_cupdates_rejected));
|
&num_cupdates_rejected);
|
||||||
if (!global_gossmap)
|
if (!global_gossmap)
|
||||||
plugin_err(plugin, "Could not load gossmap %s: %s",
|
plugin_err(plugin, "Could not load gossmap %s: %s",
|
||||||
GOSSIP_STORE_FILENAME, strerror(errno));
|
GOSSIP_STORE_FILENAME, strerror(errno));
|
||||||
@@ -705,6 +713,9 @@ static const char *init(struct plugin *p,
|
|||||||
plugin_log(plugin, LOG_DBG,
|
plugin_log(plugin, LOG_DBG,
|
||||||
"gossmap ignored %zu channel updates",
|
"gossmap ignored %zu channel updates",
|
||||||
num_cupdates_rejected);
|
num_cupdates_rejected);
|
||||||
|
#if DEVELOPER
|
||||||
|
plugin_set_memleak_handler(p, memleak_mark);
|
||||||
|
#endif
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1966,6 +1966,22 @@ def test_addgossip(node_factory):
|
|||||||
l3.rpc.addgossip(badupdate)
|
l3.rpc.addgossip(badupdate)
|
||||||
|
|
||||||
|
|
||||||
|
def test_topology_leak(node_factory, bitcoind):
|
||||||
|
l1, l2, l3 = node_factory.line_graph(3)
|
||||||
|
|
||||||
|
l1.rpc.listchannels()
|
||||||
|
bitcoind.generate_block(5)
|
||||||
|
|
||||||
|
# Wait until l1 sees all the channels.
|
||||||
|
wait_for(lambda: len(l1.rpc.listchannels()['channels']) == 4)
|
||||||
|
|
||||||
|
# Close and wait for gossip to catchup.
|
||||||
|
txid = l2.rpc.close(l3.info['id'])['txid']
|
||||||
|
bitcoind.generate_block(1, txid)
|
||||||
|
|
||||||
|
wait_for(lambda: len(l1.rpc.listchannels()['channels']) == 2)
|
||||||
|
|
||||||
|
|
||||||
def test_parms_listforwards(node_factory):
|
def test_parms_listforwards(node_factory):
|
||||||
"""
|
"""
|
||||||
Simple test to ensure that the order of the listforwards
|
Simple test to ensure that the order of the listforwards
|
||||||
|
|||||||
Reference in New Issue
Block a user