mirror of
https://github.com/hackku21/loc-chain-backend.git
synced 2024-10-27 20:34:03 +00:00
Submit transaction and remove from database
This commit is contained in:
parent
16ebe6158a
commit
289f184b4d
@ -3,6 +3,8 @@ import {TransactionResource, TransactionResourceItem} from "../../rtdb/Transacti
|
|||||||
import {Singleton, Inject} from "@extollo/di"
|
import {Singleton, Inject} from "@extollo/di"
|
||||||
import {Unit, Logging} from "@extollo/lib"
|
import {Unit, Logging} from "@extollo/lib"
|
||||||
import * as openpgp from "openpgp"
|
import * as openpgp from "openpgp"
|
||||||
|
import {Blockchain} from "../Blockchain"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transaction Unit
|
* Transaction Unit
|
||||||
* ---------------------------------------
|
* ---------------------------------------
|
||||||
@ -13,6 +15,9 @@ export class Transaction extends Unit {
|
|||||||
@Inject()
|
@Inject()
|
||||||
protected readonly firebase!: FirebaseUnit
|
protected readonly firebase!: FirebaseUnit
|
||||||
|
|
||||||
|
@Inject()
|
||||||
|
protected readonly blockchain!: Blockchain
|
||||||
|
|
||||||
public async compareTransactions(transaction1: TransactionResourceItem, transaction2: TransactionResourceItem){
|
public async compareTransactions(transaction1: TransactionResourceItem, transaction2: TransactionResourceItem){
|
||||||
// verify signature
|
// verify signature
|
||||||
const result1 = await openpgp.verify({
|
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();
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user