datastore: change keys into an array.

We store this internally as hex, since shelve insists on string keys.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2021-08-05 09:50:22 +09:30
committed by Christian Decker
parent 2ec769e05b
commit 0b9e6c9517
3 changed files with 172 additions and 55 deletions

View File

@@ -2,7 +2,6 @@
from pyln.client import Plugin, RpcError
import shelve
import os
from collections import namedtuple
plugin = Plugin()
@@ -16,9 +15,9 @@ def unload_store(plugin):
return
plugin.log("Emptying store into main store (resetting generations!)", level='unusual')
for k, (g, d) in datastore.items():
for k, (g, data) in datastore.items():
try:
plugin.rpc.datastore(k, d.hex())
plugin.rpc.datastore(key=[k], hex=d.hex())
except RpcError as e:
plugin.log("Failed to put {} into store: {}".format(k, e),
level='broken')