aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-10-19 20:16:01 +0200
committerFlorian Dold <florian.dold@gmail.com>2016-10-19 20:16:01 +0200
commit4fd1e07449c97619dbf1e0e17baa47168644dba9 (patch)
tree4f7d6a16597dd0fdd4cb2c803c8137d621e4c944 /lib
parentb0b737f72ecc3cb96acff510906db9f818eab463 (diff)
downloadwallet-core-4fd1e07449c97619dbf1e0e17baa47168644dba9.tar.xz
fix db issue
Diffstat (limited to 'lib')
-rw-r--r--lib/wallet/query.ts9
-rw-r--r--lib/wallet/wallet.ts9
2 files changed, 10 insertions, 8 deletions
diff --git a/lib/wallet/query.ts b/lib/wallet/query.ts
index 3571c32c7..c369e4b67 100644
--- a/lib/wallet/query.ts
+++ b/lib/wallet/query.ts
@@ -51,6 +51,7 @@ export class Index<S extends IDBValidKey,T> {
constructor(s: Store<T>, indexName: string, keyPath: string | string[]) {
this.storeName = s.name;
this.indexName = indexName;
+ this.keyPath = keyPath;
}
}
@@ -60,7 +61,7 @@ export class Index<S extends IDBValidKey,T> {
*/
export interface QueryStream<T> {
indexJoin<S,I extends IDBValidKey>(index: Index<I,S>,
- keyFn: (obj: T) => I): QueryStream<[T, S]>;
+ keyFn: (obj: T) => I): QueryStream<JoinResult<T, S>>;
keyJoin<S,I extends IDBValidKey>(store: Store<S>,
keyFn: (obj: T) => I): QueryStream<JoinResult<T,S>>;
filter(f: (T: any) => boolean): QueryStream<T>;
@@ -106,7 +107,7 @@ abstract class QueryStreamBase<T> implements QueryStream<T> {
}
indexJoin<S,I extends IDBValidKey>(index: Index<I,S>,
- keyFn: (obj: T) => I): QueryStream<[T, S]> {
+ keyFn: (obj: T) => I): QueryStream<JoinResult<T, S>> {
this.root.addStoreAccess(index.storeName, false);
return new QueryStreamIndexJoin(this, index.storeName, index.indexName, keyFn);
}
@@ -212,7 +213,7 @@ class QueryStreamFlatMap<T> extends QueryStreamBase<T> {
}
-class QueryStreamIndexJoin<T, S> extends QueryStreamBase<[T, S]> {
+class QueryStreamIndexJoin<T, S> extends QueryStreamBase<JoinResult<T, S>> {
s: QueryStreamBase<T>;
storeName: string;
key: any;
@@ -239,7 +240,7 @@ class QueryStreamIndexJoin<T, S> extends QueryStreamBase<[T, S]> {
req.onsuccess = () => {
let cursor = req.result;
if (cursor) {
- f(false, [value, cursor.value], tx);
+ f(false, {left: value, right: cursor.value}, tx);
cursor.continue();
} else {
f(true, undefined, tx);
diff --git a/lib/wallet/wallet.ts b/lib/wallet/wallet.ts
index 380243b44..851b7b048 100644
--- a/lib/wallet/wallet.ts
+++ b/lib/wallet/wallet.ts
@@ -320,7 +320,7 @@ export namespace Stores {
super("coins", {keyPath: "coinPub"});
}
- exchangeBaseUrlIndex = new Index<string,Coin>(this, "exchangeBaseUrl", "exchageBaseUrl");
+ exchangeBaseUrlIndex = new Index<string,Coin>(this, "exchangeBaseUrl", "exchangeBaseUrl");
}
class HistoryStore extends Store<HistoryRecord> {
@@ -461,10 +461,10 @@ export class Wallet {
let x: number;
- function storeExchangeCoin(mc: any, url: string) {
- let exchange: IExchangeInfo = mc[0];
+ function storeExchangeCoin(mc: JoinResult<IExchangeInfo, Coin>, url: string) {
+ let exchange: IExchangeInfo = mc.left;
console.log("got coin for exchange", url);
- let coin: Coin = mc[1];
+ let coin: Coin = mc.right;
if (coin.suspended) {
console.log("skipping suspended coin",
coin.denomPub,
@@ -517,6 +517,7 @@ export class Wallet {
console.log("not suitable exchanges found");
}
+ console.log("exchange coins:");
console.dir(m);
// We try to find the first exchange where we have