1
0

follow-up prev: try to handle json db int key madness :/

This commit is contained in:
SomberNight
2020-03-17 20:27:18 +01:00
parent b524460fdf
commit 9a70b79eea
2 changed files with 10 additions and 3 deletions

View File

@@ -76,7 +76,10 @@ class StoredDict(dict):
self.__setitem__(k, v)
def convert_key(self, key):
# convert int, HTLCOwner to str
"""Convert int keys to str keys, as only those are allowed in json."""
# NOTE: this is evil. really hard to keep in mind and reason about. :(
# e.g.: imagine setting int keys everywhere, and then iterating over the dict:
# suddenly the keys are str...
return str(int(key)) if isinstance(key, int) else key
@locked