commando: add filtering support.

1. When we receive a commando command from a remote using the `filter`
   field, use it.
2. Add a `filter` parameter to `commando` to send it: this is usually
   more efficient than using filtering locally.

Of course, older remote nodes will ignore the filter, but that's
harmless.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: Plugins: `commando` now supports `filter` as a parameter (for send and receive).
This commit is contained in:
Rusty Russell
2023-01-03 14:53:28 +10:30
parent 1250806060
commit 3f0c5b985b
3 changed files with 24 additions and 2 deletions

View File

@@ -2648,6 +2648,14 @@ def test_commando(node_factory, executor):
assert len(res['peers']) == 1
assert res['peers'][0]['id'] == l2.info['id']
# Filter test
res = l2.rpc.call(method='commando',
payload={'peer_id': l1.info['id'],
'rune': rune,
'method': 'listpeers',
'filter': {'peers': [{'id': True}]}})
assert res == {'peers': [{'id': l2.info['id']}]}
with pytest.raises(RpcError, match='missing required parameter'):
l2.rpc.call(method='commando',
payload={'peer_id': l1.info['id'],