1
0

storage: encapsulate type conversions of stored objects using

decorators (instead of overloading JsonDB._convert_dict and
 _convert_value)
 - stored_in for elements of a StoreDict
 - stored_as for singletons
 - extra register methods are defined for key conversions

This commit was adapted from the jsonpatch branch
This commit is contained in:
ThomasV
2021-10-05 09:13:01 +02:00
parent 079c0ce5b2
commit 295734fc53
7 changed files with 119 additions and 73 deletions

View File

@@ -19,7 +19,7 @@ from .lnutil import REDEEM_AFTER_DOUBLE_SPENT_DELAY, ln_dummy_address
from .bitcoin import dust_threshold
from .logging import Logger
from .lnutil import hex_to_bytes
from .json_db import StoredObject
from .json_db import StoredObject, stored_in
from . import constants
from .address_synchronizer import TX_HEIGHT_LOCAL
from .i18n import _
@@ -87,6 +87,7 @@ class SwapServerError(Exception):
return _("The swap server errored or is unreachable.")
@stored_in('submarine_swaps')
@attr.s
class SwapData(StoredObject):
is_reverse = attr.ib(type=bool)