From 218c7d5bd6a918bd177982f9728ab809e1a3345b Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 18 Oct 2016 01:47:40 +0200 Subject: be even more safe in db --- lib/wallet/wallet.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'lib/wallet/wallet.ts') diff --git a/lib/wallet/wallet.ts b/lib/wallet/wallet.ts index 54c979919..f55ba2170 100644 --- a/lib/wallet/wallet.ts +++ b/lib/wallet/wallet.ts @@ -329,9 +329,17 @@ namespace Stores { timestampIndex = new Index(this, "timestamp"); } + class TransactionsStore extends Store { + constructor() { + super("transactions"); + } + + repurchaseIndex = new Index<[string,string],Transaction>(this, "repurchase"); + } + export let exchanges: ExchangeStore = new ExchangeStore(); - export let transactions: Store = new Store("transactions"); + export let transactions: TransactionsStore = new TransactionsStore(); export let reserves: Store = new Store("reserves"); export let coins: CoinsStore = new CoinsStore(); export let refresh: Store = new Store("refresh"); @@ -1444,10 +1452,9 @@ export class Wallet { console.log("no repurchase: no correlation id"); return {isRepurchase: false}; } - let result: Transaction = await ( + let result: Transaction|undefined = await ( this.q() - .getIndexed("transactions", - "repurchase", + .getIndexed(Stores.transactions.repurchaseIndex, [ contract.merchant_pub, contract.repurchase_correlation_id -- cgit v1.2.3