mirror of
https://github.com/hackku21/loc-chain-backend.git
synced 2024-10-27 20:34:03 +00:00
Reduce locking on block ref
This commit is contained in:
parent
d79d0f38f4
commit
d8e7a85122
@ -119,9 +119,9 @@ export interface Peer {
|
|||||||
*/
|
*/
|
||||||
@Singleton()
|
@Singleton()
|
||||||
export class Blockchain extends Unit {
|
export class Blockchain extends Unit {
|
||||||
private readonly MIN_WAIT_TIME = 30
|
private readonly MIN_WAIT_TIME = 10000
|
||||||
private readonly MAX_WAIT_TIME = 500
|
private readonly MAX_WAIT_TIME = 20000
|
||||||
private readonly PENALTY_INTERVAL = 100
|
private readonly PENALTY_INTERVAL = 1000
|
||||||
private readonly MAX_PEERS_PENALTY = 10
|
private readonly MAX_PEERS_PENALTY = 10
|
||||||
|
|
||||||
@Inject()
|
@Inject()
|
||||||
|
@ -47,7 +47,7 @@ export class Exposure extends Unit {
|
|||||||
this.firebase.ref('exposure').on('child_added', async (snapshot) => {
|
this.firebase.ref('exposure').on('child_added', async (snapshot) => {
|
||||||
this.logging.debug('Received child_added event for exposures reference.')
|
this.logging.debug('Received child_added event for exposures reference.')
|
||||||
if ( !this.claim() ) return
|
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()
|
const exposure: ExposureResourceItem = snapshot.val()
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ export class Exposure extends Unit {
|
|||||||
await (<ExposureResource> this.make(ExposureResource)).ref().child(snapshot.key).remove()
|
await (<ExposureResource> this.make(ExposureResource)).ref().child(snapshot.key).remove()
|
||||||
|
|
||||||
this.release()
|
this.release()
|
||||||
await this.firebase.unlock('block')
|
// await this.firebase.unlock('block')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,6 +83,7 @@ export class Transaction extends Unit {
|
|||||||
let groupedTransactions: [TransactionResourceItem, TransactionResourceItem][] = []
|
let groupedTransactions: [TransactionResourceItem, TransactionResourceItem][] = []
|
||||||
// collection of transaction resource items
|
// collection of transaction resource items
|
||||||
let transactions = await TransactionResource.collect().collect()
|
let transactions = await TransactionResource.collect().collect()
|
||||||
|
await this.firebase.unlock('block')
|
||||||
|
|
||||||
// compare each item
|
// compare each item
|
||||||
await transactions.promiseMap(async transaction1 => {
|
await transactions.promiseMap(async transaction1 => {
|
||||||
@ -111,6 +112,7 @@ export class Transaction extends Unit {
|
|||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
await this.firebase.trylock('block', 'Transaction_submitTransactions')
|
||||||
for (const group of groupedTransactions) {
|
for (const group of groupedTransactions) {
|
||||||
const block = await this.blockchain.submitTransactions(group)
|
const block = await this.blockchain.submitTransactions(group)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user