mirror of
https://github.com/aljazceru/plugins.git
synced 2025-12-20 14:44:20 +01:00
datastore.py: update to meet new datastore builtin PR.
The new datastore PR now has a generation count; this passes the tests against that now. Also copies tests from c-lightning, and adds ugprade test. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
941c1b7141
commit
2ec769e05b
@@ -2,6 +2,7 @@
|
||||
from pyln.client import Plugin, RpcError
|
||||
import shelve
|
||||
import os
|
||||
from collections import namedtuple
|
||||
|
||||
|
||||
plugin = Plugin()
|
||||
@@ -10,12 +11,12 @@ plugin = Plugin()
|
||||
def unload_store(plugin):
|
||||
"""When we have a real store, we transfer our contents into it"""
|
||||
try:
|
||||
datastore = shelve.open('datastore.dat', 'r')
|
||||
datastore = shelve.open('datastore_v1.dat', 'r')
|
||||
except:
|
||||
return
|
||||
|
||||
plugin.log("Emptying store into main store!", level='unusual')
|
||||
for k, d in datastore.items():
|
||||
plugin.log("Emptying store into main store (resetting generations!)", level='unusual')
|
||||
for k, (g, d) in datastore.items():
|
||||
try:
|
||||
plugin.rpc.datastore(k, d.hex())
|
||||
except RpcError as e:
|
||||
@@ -23,7 +24,7 @@ def unload_store(plugin):
|
||||
level='broken')
|
||||
datastore.close()
|
||||
plugin.log("Erasing our store", level='unusual')
|
||||
os.unlink('datastore.dat')
|
||||
os.unlink('datastore_v1.dat')
|
||||
|
||||
|
||||
@plugin.init()
|
||||
|
||||
Reference in New Issue
Block a user