diff --git a/src/app/units/Blockchain.ts b/src/app/units/Blockchain.ts index 4a681ed..f84cf0e 100644 --- a/src/app/units/Blockchain.ts +++ b/src/app/units/Blockchain.ts @@ -119,9 +119,9 @@ export interface Peer { */ @Singleton() export class Blockchain extends Unit { - private readonly MIN_WAIT_TIME = 30 - private readonly MAX_WAIT_TIME = 500 - private readonly PENALTY_INTERVAL = 100 + private readonly MIN_WAIT_TIME = 10000 + private readonly MAX_WAIT_TIME = 20000 + private readonly PENALTY_INTERVAL = 1000 private readonly MAX_PEERS_PENALTY = 10 @Inject() diff --git a/src/app/units/rtdb/Exposure.ts b/src/app/units/rtdb/Exposure.ts index 940c086..657ff94 100644 --- a/src/app/units/rtdb/Exposure.ts +++ b/src/app/units/rtdb/Exposure.ts @@ -47,7 +47,7 @@ export class Exposure extends Unit { this.firebase.ref('exposure').on('child_added', async (snapshot) => { this.logging.debug('Received child_added event for exposures reference.') if ( !this.claim() ) return - await this.firebase.trylock('block', 'Exposure_child_added') + // await this.firebase.trylock('block', 'Exposure_child_added') const exposure: ExposureResourceItem = snapshot.val() @@ -58,7 +58,7 @@ export class Exposure extends Unit { await ( this.make(ExposureResource)).ref().child(snapshot.key).remove() this.release() - await this.firebase.unlock('block') + // await this.firebase.unlock('block') }) } diff --git a/src/app/units/rtdb/Transaction.ts b/src/app/units/rtdb/Transaction.ts index 0e9452b..47ae6d1 100644 --- a/src/app/units/rtdb/Transaction.ts +++ b/src/app/units/rtdb/Transaction.ts @@ -83,6 +83,7 @@ export class Transaction extends Unit { let groupedTransactions: [TransactionResourceItem, TransactionResourceItem][] = [] // collection of transaction resource items let transactions = await TransactionResource.collect().collect() + await this.firebase.unlock('block') // compare each item await transactions.promiseMap(async transaction1 => { @@ -111,6 +112,7 @@ export class Transaction extends Unit { return false }) + await this.firebase.trylock('block', 'Transaction_submitTransactions') for (const group of groupedTransactions) { const block = await this.blockchain.submitTransactions(group)