mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
commando: always active.
We used to activate on the first rune creation, but we're no longer in charge of runes, so we can't make that call. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -50,7 +50,7 @@ struct blacklist {
|
|||||||
static struct plugin *plugin;
|
static struct plugin *plugin;
|
||||||
static struct commando **outgoing_commands;
|
static struct commando **outgoing_commands;
|
||||||
static struct commando **incoming_commands;
|
static struct commando **incoming_commands;
|
||||||
static u64 *rune_counter;
|
static u64 rune_counter;
|
||||||
static struct rune *master_rune;
|
static struct rune *master_rune;
|
||||||
static struct blacklist *blacklist;
|
static struct blacklist *blacklist;
|
||||||
|
|
||||||
@@ -602,9 +602,6 @@ static void handle_incmd(struct node_id *peer,
|
|||||||
{
|
{
|
||||||
struct commando *incmd;
|
struct commando *incmd;
|
||||||
|
|
||||||
if (!rune_counter)
|
|
||||||
return;
|
|
||||||
|
|
||||||
incmd = find_commando(incoming_commands, peer, NULL);
|
incmd = find_commando(incoming_commands, peer, NULL);
|
||||||
/* Don't let them buffer multiple commands: discard old. */
|
/* Don't let them buffer multiple commands: discard old. */
|
||||||
if (incmd && incmd->id != idnum) {
|
if (incmd && incmd->id != idnum) {
|
||||||
@@ -1092,8 +1089,7 @@ static struct command_result *json_commando_rune(struct command *cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
rune = rune_derive_start(cmd, master_rune,
|
rune = rune_derive_start(cmd, master_rune,
|
||||||
tal_fmt(tmpctx, "%"PRIu64,
|
tal_fmt(tmpctx, "%"PRIu64, rune_counter));
|
||||||
rune_counter ? *rune_counter : 0));
|
|
||||||
for (size_t i = 0; i < tal_count(restrs); i++)
|
for (size_t i = 0; i < tal_count(restrs); i++)
|
||||||
rune_add_restr(rune, restrs[i]);
|
rune_add_restr(rune, restrs[i]);
|
||||||
|
|
||||||
@@ -1105,17 +1101,14 @@ static struct command_result *json_commando_rune(struct command *cmd,
|
|||||||
json_add_string(req->js, NULL, "rune_counter");
|
json_add_string(req->js, NULL, "rune_counter");
|
||||||
json_array_end(req->js);
|
json_array_end(req->js);
|
||||||
if (rune_counter) {
|
if (rune_counter) {
|
||||||
(*rune_counter)++;
|
|
||||||
json_add_string(req->js, "mode", "must-replace");
|
json_add_string(req->js, "mode", "must-replace");
|
||||||
} else {
|
} else {
|
||||||
/* This used to say "🌩🤯🧨🔫!" but our log filters are too strict :( */
|
/* This used to say "🌩🤯🧨🔫!" but our log filters are too strict :( */
|
||||||
plugin_log(plugin, LOG_INFORM, "Commando powers enabled: BOOM!");
|
plugin_log(plugin, LOG_INFORM, "Commando powers enabled: BOOM!");
|
||||||
rune_counter = tal(plugin, u64);
|
|
||||||
*rune_counter = 1;
|
|
||||||
json_add_string(req->js, "mode", "must-create");
|
json_add_string(req->js, "mode", "must-create");
|
||||||
}
|
}
|
||||||
json_add_string(req->js, "string",
|
rune_counter++;
|
||||||
tal_fmt(tmpctx, "%"PRIu64, *rune_counter));
|
json_add_string(req->js, "string", tal_fmt(tmpctx, "%"PRIu64, rune_counter));
|
||||||
return send_outreq(plugin, req);
|
return send_outreq(plugin, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1346,8 +1339,6 @@ static void memleak_mark_globals(struct plugin *p, struct htable *memtable)
|
|||||||
memleak_scan_obj(memtable, master_rune);
|
memleak_scan_obj(memtable, master_rune);
|
||||||
memleak_scan_htable(memtable, &usage_table->raw);
|
memleak_scan_htable(memtable, &usage_table->raw);
|
||||||
memleak_scan_obj(memtable, blacklist);
|
memleak_scan_obj(memtable, blacklist);
|
||||||
if (rune_counter)
|
|
||||||
memleak_scan_obj(memtable, rune_counter);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1378,12 +1369,11 @@ static const char *init(struct plugin *p,
|
|||||||
plugin_set_memleak_handler(p, memleak_mark_globals);
|
plugin_set_memleak_handler(p, memleak_mark_globals);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rune_counter = tal(p, u64);
|
|
||||||
/* If this fails, it probably doesn't exist */
|
/* If this fails, it probably doesn't exist */
|
||||||
err = rpc_scan_datastore_str(tmpctx, plugin, "commando/rune_counter",
|
err = rpc_scan_datastore_str(tmpctx, plugin, "commando/rune_counter",
|
||||||
JSON_SCAN(json_to_u64, rune_counter));
|
JSON_SCAN(json_to_u64, &rune_counter));
|
||||||
if (err)
|
if (err)
|
||||||
rune_counter = tal_free(rune_counter);
|
rune_counter = 0;
|
||||||
|
|
||||||
/* Old python commando used to store secret */
|
/* Old python commando used to store secret */
|
||||||
err = rpc_scan_datastore_hex(tmpctx, plugin, "commando/secret",
|
err = rpc_scan_datastore_hex(tmpctx, plugin, "commando/secret",
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ from utils import (
|
|||||||
|
|
||||||
import ast
|
import ast
|
||||||
import base64
|
import base64
|
||||||
import concurrent.futures
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
@@ -2617,13 +2616,6 @@ def test_commando(node_factory, executor):
|
|||||||
l1, l2 = node_factory.line_graph(2, fundchannel=False,
|
l1, l2 = node_factory.line_graph(2, fundchannel=False,
|
||||||
opts={'log-level': 'io'})
|
opts={'log-level': 'io'})
|
||||||
|
|
||||||
# Nothing works until we've issued a rune.
|
|
||||||
fut = executor.submit(l2.rpc.call, method='commando',
|
|
||||||
payload={'peer_id': l1.info['id'],
|
|
||||||
'method': 'listpeers'})
|
|
||||||
with pytest.raises(concurrent.futures.TimeoutError):
|
|
||||||
fut.result(10)
|
|
||||||
|
|
||||||
rune = l1.rpc.commando_rune()['rune']
|
rune = l1.rpc.commando_rune()['rune']
|
||||||
|
|
||||||
# Bad rune fails
|
# Bad rune fails
|
||||||
|
|||||||
Reference in New Issue
Block a user