mirror of
https://github.com/hackku21/loc-chain-backend.git
synced 2024-10-27 20:34:03 +00:00
Properly trylock consensus DB writes
This commit is contained in:
parent
f072d81b5f
commit
1423e1961e
@ -79,8 +79,6 @@ export class FirebaseResource<T extends FirebaseResourceItem> extends Iterable<T
|
||||
* @param item
|
||||
*/
|
||||
async push(item: T): Promise<T> {
|
||||
await this.firebase.trylock(this.refName)
|
||||
|
||||
await this.ref().transaction((collection) => {
|
||||
if ( !collection ) collection = []
|
||||
item.seqID = this.findNextId(collection)
|
||||
@ -103,7 +101,6 @@ export class FirebaseResource<T extends FirebaseResourceItem> extends Iterable<T
|
||||
})
|
||||
})
|
||||
|
||||
await this.firebase.unlock(this.refName)
|
||||
return item
|
||||
}
|
||||
|
||||
|
@ -281,6 +281,7 @@ export class Blockchain extends Unit {
|
||||
this.isSubmitting = true
|
||||
}
|
||||
|
||||
await this.firebase.trylock('block')
|
||||
const validSeqID = (await this.read()).reverse()[0]?.seqID
|
||||
|
||||
const peers = await this.getPeers()
|
||||
@ -347,6 +348,7 @@ export class Blockchain extends Unit {
|
||||
await this.attemptSubmit()
|
||||
}
|
||||
|
||||
await this.firebase.unlock('block')
|
||||
this.isSubmitting = false
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user