keys: add a way to remove all bonds from key store

This commit is contained in:
Abel Lucas
2022-11-17 02:54:37 +00:00
parent 4988a31487
commit 9c133706e6

View File

@@ -20,6 +20,7 @@
# -----------------------------------------------------------------------------
# Imports
# -----------------------------------------------------------------------------
import asyncio
import logging
import os
import json
@@ -143,6 +144,10 @@ class KeyStore:
async def get_all(self):
return []
async def delete_all(self):
all_keys = await self.get_all()
await asyncio.gather(*(self.delete(name) for (name, _) in all_keys))
async def get_resolving_keys(self):
all_keys = await self.get_all()
resolving_keys = []
@@ -259,6 +264,13 @@ class JsonKeyStore(KeyStore):
return [(name, PairingKeys.from_dict(keys)) for (name, keys) in namespace.items()]
async def delete_all(self):
db = await self.load()
db.pop(self.namespace, None)
await self.save(db)
async def get(self, name):
db = await self.load()