mirror of
https://github.com/aljazceru/nutshell.git
synced 2026-01-04 17:34:20 +01:00
[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:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user