Reduce locking on block ref

This commit is contained in:
Garrett Mills 2021-04-10 16:35:42 -05:00
parent d79d0f38f4
commit d8e7a85122
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246
3 changed files with 7 additions and 5 deletions

View File

@ -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()

View File

@ -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 (<ExposureResource> this.make(ExposureResource)).ref().child(snapshot.key).remove()
this.release()
await this.firebase.unlock('block')
// await this.firebase.unlock('block')
})
}

View File

@ -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)