[Mint] Fix key rotation (#177)

* rotate keys every 5 seconds

* every 10 seconds

* do not regenerate all past keys for each epoch cycle

* remove automatic rotation

* make format

* print to logger

* rephrase print
This commit is contained in:
calle
2023-04-26 20:20:17 +02:00
committed by GitHub
parent 28812919ac
commit 87f9241de1
3 changed files with 39 additions and 7 deletions

View File

@@ -1,6 +1,7 @@
# startup routine of the standalone app. These are the steps that need
# to be taken by external apps importing the cashu mint.
import asyncio
import importlib
from loguru import logger
@@ -28,6 +29,20 @@ ledger = Ledger(
)
async def rotate_keys(n_seconds=10):
"""Rotate keyset epoch every n_seconds.
Note: This is just a helper function for testing purposes.
"""
i = 0
while True:
i += 1
logger.info("Rotating keys.")
ledger.derivation_path = f"0/0/0/{i}"
await ledger.init_keysets()
logger.info(f"Current keyset: {ledger.keyset.id}")
await asyncio.sleep(n_seconds)
async def start_mint_init():
await migrate_databases(ledger.db, migrations)
await ledger.load_used_proofs()
@@ -45,3 +60,4 @@ async def start_mint_init():
logger.info(f"Data dir: {settings.cashu_dir}")
logger.info("Mint started.")
# asyncio.create_task(rotate_keys())