wallet-core: make coin availability accounting idempotent

This commit is contained in:
Florian Dold 2022-09-19 12:48:11 +02:00
parent d759c7e78a
commit d34f8e48da
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
2 changed files with 7 additions and 1 deletions

View File

@ -522,7 +522,9 @@ async function refreshReveal(
refreshGroupId: string,
coinIndex: number,
): Promise<void> {
logger.info("doing refresh reveal");
logger.info(
`doing refresh reveal for ${refreshGroupId} (old coin ${coinIndex})`,
);
const d = await ws.db
.mktx((x) => [x.refreshGroups, x.coins, x.denominations])
.runReadOnly(async (tx) => {

View File

@ -810,6 +810,10 @@ export async function makeCoinAvailable(
}>,
coinRecord: CoinRecord,
): Promise<void> {
const existingCoin = await tx.coins.get(coinRecord.coinPub);
if (existingCoin) {
return;
}
const denom = await tx.denominations.get([
coinRecord.exchangeBaseUrl,
coinRecord.denomPubHash,