Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc committed Mar 23, 2024
1 parent 2fe20fd commit 30fe7ba
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions cashu/mint/startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,28 +68,25 @@ async def rotate_keys(n_seconds=60):
i = 0
new_keyset = ledger.keyset
while True:
await asyncio.sleep(n_seconds)
i += 1
old_keyset = new_keyset
logger.info(f"Rotating keys. Old keyset: {old_keyset.id}.")

incremented_derivation_path = (
"/".join(ledger.derivation_path.split("/")[:-1]) + f"/{i}"
)
new_keyset = await ledger.activate_keyset(
derivation_path=incremented_derivation_path
)

logger.info(
f"Derivation path: {incremented_derivation_path} – New keyset: {new_keyset.id}. Deactivating old keyset {old_keyset.id}."
)

# deactivate old keyset and update ledger.keyset
ledger.keysets[old_keyset.id] = await ledger.crud.deactivate_keyset(
db=ledger.db, keyset=old_keyset
)

logger.info(f"All keysets: {ledger.keysets}")

await asyncio.sleep(n_seconds)
logger.info(
f"Rotate keyset and deactivated old one: {old_keyset.id} -> {new_keyset.id}."
)


async def start_mint_init():
Expand Down

0 comments on commit 30fe7ba

Please sign in to comment.