Add ability to clear the cache values for a specific ritual - for now it beneficial for testing; perhaps can be good for future revoke functionality.

remotes/origin/v7.4.x
derekpierre 2024-02-01 20:13:23 -05:00 committed by Derek Pierre
parent 083df6664f
commit 31e1c18a69
1 changed files with 19 additions and 1 deletions

View File

@ -22,9 +22,24 @@ class DKGStorage:
# active rituals
KEY_DECRYPTION_SHARE = "decryption_share"
_KEYS = [
KEY_TRANSCRIPT_TXS,
KEY_VALIDATORS,
KEY_AGGREGATED_TXS,
KEY_AGGREGATED_TRANSCRIPTS,
KEY_DECRYPTION_SHARE,
]
def __init__(self):
self.data = defaultdict(dict)
def clear(self, ritual_id):
for key in self._KEYS:
try:
del self.data[key][ritual_id]
except KeyError:
continue
#
# DKG Round 1 - Transcripts
#
@ -45,6 +60,9 @@ class DKGStorage:
def get_validators(self, ritual_id: int) -> Optional[List[Validator]]:
validators = self.data[self.KEY_VALIDATORS].get(ritual_id)
if not validators:
return None
return list(validators)
#
@ -80,7 +98,7 @@ class DKGStorage:
return self.data[self.KEY_AGGREGATED_TXS].get(ritual_id)
#
# Completed DKG
# Active Rituals
#
def store_decryption_share(
self,