Submit transaction and remove from database

This commit is contained in:
QiTao Weng 2021-04-10 07:30:39 +00:00
parent 16ebe6158a
commit 289f184b4d

View File

@ -3,6 +3,8 @@ import {TransactionResource, TransactionResourceItem} from "../../rtdb/Transacti
import {Singleton, Inject} from "@extollo/di"
import {Unit, Logging} from "@extollo/lib"
import * as openpgp from "openpgp"
import {Blockchain} from "../Blockchain"
/**
* Transaction Unit
* ---------------------------------------
@ -13,6 +15,9 @@ export class Transaction extends Unit {
@Inject()
protected readonly firebase!: FirebaseUnit
@Inject()
protected readonly blockchain!: Blockchain
public async compareTransactions(transaction1: TransactionResourceItem, transaction2: TransactionResourceItem){
// verify signature
const result1 = await openpgp.verify({
@ -57,6 +62,11 @@ export class Transaction extends Unit {
}
})
})
for (const group of groupedTransactions) {
await this.blockchain.submitTransactions(group);
await this.firebase.ref("transaction").child(group[0].firebaseID).remove();
await this.firebase.ref("transaction").child(group[1].firebaseID).remove();
}
})
}