fix schema issues

This commit is contained in:
Florian Dold 2016-02-19 01:25:56 +01:00
parent f79533614f
commit 07f11151aa
2 changed files with 10 additions and 9 deletions

View File

@ -46,7 +46,7 @@ export function openTalerDb(): Promise<IDBDatabase> {
switch (e.oldVersion) { switch (e.oldVersion) {
case 0: // DB does not exist yet case 0: // DB does not exist yet
const mints = db.createObjectStore("mints", {keyPath: "baseUrl"}); const mints = db.createObjectStore("mints", {keyPath: "baseUrl"});
mints.createIndex("pubKey", "keys.master_public_key"); mints.createIndex("pubKey", "masterPublicKey");
db.createObjectStore("reserves", {keyPath: "reserve_pub"}); db.createObjectStore("reserves", {keyPath: "reserve_pub"});
db.createObjectStore("denoms", {keyPath: "denomPub"}); db.createObjectStore("denoms", {keyPath: "denomPub"});
const coins = db.createObjectStore("coins", {keyPath: "coinPub"}); const coins = db.createObjectStore("coins", {keyPath: "coinPub"});

View File

@ -502,11 +502,11 @@ export class Wallet {
let m: MintCoins = {}; let m: MintCoins = {};
function storeMintCoin(mc) { function storeMintCoin(mc) {
let mint = mc[0]; let mint: IMintInfo = mc[0];
let coin = mc[1]; let coin = mc[1];
let cd = { let cd = {
coin: coin, coin: coin,
denom: mint.keys.denoms.find((e) => e.denom_pub === coin.denomPub) denom: mint.denoms.find((e) => e.denom_pub === coin.denomPub)
}; };
if (!cd.denom) { if (!cd.denom) {
throw Error("denom not found (database inconsistent)"); throw Error("denom not found (database inconsistent)");
@ -520,6 +520,7 @@ export class Wallet {
} }
let ps = allowedMints.map((info) => { let ps = allowedMints.map((info) => {
console.log("Checking for merchant's mint", JSON.stringify(info));
return Query(this.db) return Query(this.db)
.iter("mints", {indexName: "pubKey", only: info.master_pub}) .iter("mints", {indexName: "pubKey", only: info.master_pub})
.indexJoin("coins", "mintBaseUrl", (mint) => mint.baseUrl) .indexJoin("coins", "mintBaseUrl", (mint) => mint.baseUrl)
@ -947,25 +948,25 @@ export class Wallet {
let mintKeysJson = KeysJson.checked(JSON.parse(resp.responseText)); let mintKeysJson = KeysJson.checked(JSON.parse(resp.responseText));
return Query(this.db).get("mints", baseUrl).then((r) => { return Query(this.db).get("mints", baseUrl).then((r) => {
let mint; let mintInfo;
console.log("got mints result"); console.log("got mints result");
console.dir(r); console.dir(r);
if (!r) { if (!r) {
mint = MintInfo.fresh(baseUrl); mintInfo = MintInfo.fresh(baseUrl);
console.log("making fresh mint"); console.log("making fresh mint");
} else { } else {
mint = new MintInfo(r); mintInfo = new MintInfo(r);
console.log("using old mint"); console.log("using old mint");
} }
return mint.mergeKeys(mintKeysJson) return mintInfo.mergeKeys(mintKeysJson, this)
.then(() => { .then(() => {
return Query(this.db) return Query(this.db)
.put("mints", mint) .put("mints", mintInfo)
.finish() .finish()
.then(() => mint); .then(() => mintInfo);
}); });
}); });