diff --git a/src/app/configs/server.config.ts b/src/app/configs/server.config.ts index 704fc13..971d50f 100644 --- a/src/app/configs/server.config.ts +++ b/src/app/configs/server.config.ts @@ -4,10 +4,9 @@ import {LocalFilesystem, LocalFilesystemConfig} from "@extollo/util" export default { debug: env('DEBUG_MODE', false), - base_url: env('BASE_URL', 'http://localhost:8000/'), + base_url: env('BASE_URL', 'http://192.168.0.29:8000/'), peers: [ - 'http://127.0.0.1:8100/', ], session: { diff --git a/src/app/units/Blockchain.ts b/src/app/units/Blockchain.ts index b528dd6..aa856a3 100644 --- a/src/app/units/Blockchain.ts +++ b/src/app/units/Blockchain.ts @@ -281,7 +281,7 @@ export class Blockchain extends Unit { this.isSubmitting = true } - await this.firebase.trylock('block') + await this.firebase.trylock('block', 'Blockchain_refresh') const validSeqID = (await this.read()).reverse()[0]?.seqID const peers = await this.getPeers() diff --git a/src/app/units/FirebaseUnit.ts b/src/app/units/FirebaseUnit.ts index 3da2cae..d0b9966 100644 --- a/src/app/units/FirebaseUnit.ts +++ b/src/app/units/FirebaseUnit.ts @@ -40,14 +40,16 @@ export class FirebaseUnit extends Unit { * Try to lock the given database ref alias. * Promise will sleep if lock is held, and will resolve once lock is acquired. * @param name + * @param description */ - async trylock(name: RTDBRef): Promise { + async trylock(name: RTDBRef, description: string): Promise { return this._firebase.database() .ref(`${this.config.get('app.firebase.rtdb.refs.locks')}/${name}`) .transaction(current => { if ( !current || current.time < 1 ) { return { time: (new Date).getTime(), + description, } } }, undefined, false).then(async result => { @@ -58,12 +60,12 @@ export class FirebaseUnit extends Unit { this.logging.debug(`Unable to acquire lock: ${name}. Trying again soon...`) await this.sleep(500) - return this.trylock(name) + return this.trylock(name, description) }) .catch(async reason => { this.logging.debug(`Unable to acquire lock: ${name}. Trying again soon...`) await this.sleep(500) - return this.trylock(name) + return this.trylock(name, description) }) } @@ -74,7 +76,7 @@ export class FirebaseUnit extends Unit { async unlock(name: RTDBRef) { await this._firebase.database() .ref(`${this.config.get('app.firebase.rtdb.refs.locks')}/${name}`) - .set({time: 0}, err => { + .set({time: 0, description: 'none'}, err => { if ( err ) this.logging.error(err) }) } diff --git a/src/app/units/rtdb/Exposure.ts b/src/app/units/rtdb/Exposure.ts index 2979851..940c086 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') + await this.firebase.trylock('block', 'Exposure_child_added') const exposure: ExposureResourceItem = snapshot.val() diff --git a/src/app/units/rtdb/Transaction.ts b/src/app/units/rtdb/Transaction.ts index 1407ac2..0e9452b 100644 --- a/src/app/units/rtdb/Transaction.ts +++ b/src/app/units/rtdb/Transaction.ts @@ -77,7 +77,7 @@ export class Transaction extends Unit { this.firebase.ref("transaction").on("child_added", async () => { this.logging.debug('Received child_added event for transactions reference.') if ( !this.claim() ) return - await this.firebase.trylock('block') + await this.firebase.trylock('block', 'Transaction_child_added') // array of pairs of transaction resource items let groupedTransactions: [TransactionResourceItem, TransactionResourceItem][] = []