mirror of
https://github.com/hackku21/loc-chain-backend.git
synced 2024-10-27 20:34:03 +00:00
Fix transaction deletion
This commit is contained in:
parent
b8bf02bc12
commit
327d1a6ebd
@ -63,15 +63,17 @@ export class Transaction extends Unit {
|
|||||||
*/
|
*/
|
||||||
public async up() {
|
public async up() {
|
||||||
this.firebase.ref('transaction').on('value', snapshot => {
|
this.firebase.ref('transaction').on('value', snapshot => {
|
||||||
if ( !Array.isArray(snapshot.val()) || snapshot.val().length < 2 ) return;
|
for ( const leftKey in snapshot.val() ) {
|
||||||
let newSnapshot = [...snapshot.val()]
|
const left = snapshot.val()[leftKey]
|
||||||
for ( const left of snapshot.val() ) {
|
|
||||||
for ( const right of snapshot.val() ) {
|
for ( const rightKey in snapshot.val() ) {
|
||||||
|
const right = snapshot.val()[rightKey]
|
||||||
|
|
||||||
this.compare(left, right).then(match => {
|
this.compare(left, right).then(match => {
|
||||||
if ( match ) {
|
if ( match ) {
|
||||||
this.blockchain.submitTransactions([left, right])
|
this.blockchain.submitTransactions([left, right])
|
||||||
this.firebase.ref('transaction').child(left.key).remove()
|
this.firebase.ref('transaction').child(leftKey).remove()
|
||||||
this.firebase.ref('transaction').child(right.key).remove()
|
this.firebase.ref('transaction').child(rightKey).remove()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user