flushTransaction() lock
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
export function applyFills( orderStatus, filled ) {
|
export function applyFills( orderStatus, filled ) {
|
||||||
console.log('apply fills', orderStatus, filled)
|
// console.log('apply fills', orderStatus, filled)
|
||||||
orderStatus[4] = filled[0][0]
|
orderStatus[4] = filled[0][0]
|
||||||
orderStatus[5] = filled[0][1]
|
orderStatus[5] = filled[0][1]
|
||||||
for( const i in filled[1] ) {
|
for( const i in filled[1] ) {
|
||||||
@@ -7,5 +7,5 @@ export function applyFills( orderStatus, filled ) {
|
|||||||
orderStatus[6][i] = filledIn
|
orderStatus[6][i] = filledIn
|
||||||
orderStatus[7][i] = filledOut
|
orderStatus[7][i] = filledOut
|
||||||
}
|
}
|
||||||
console.log('applied fills', orderStatus)
|
// console.log('applied fills', orderStatus)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,12 +199,25 @@ export function pendTransaction(sender) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let flushing = 0 // semaphore
|
||||||
|
|
||||||
export function flushTransactions() {
|
export function flushTransactions() {
|
||||||
// noinspection JSIgnoredPromiseFromCall
|
flushing++
|
||||||
asyncFlushTransactions()
|
if( flushing === 1 )
|
||||||
|
// noinspection JSIgnoredPromiseFromCall
|
||||||
|
asyncFlushTransactions()
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function asyncFlushTransactions() {
|
export async function asyncFlushTransactions() {
|
||||||
|
let counter
|
||||||
|
do {
|
||||||
|
counter = flushing
|
||||||
|
await asyncFlushTransactions2()
|
||||||
|
} while( flushing > counter)
|
||||||
|
flushing = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function asyncFlushTransactions2() {
|
||||||
// todo rework into flushTransactions()
|
// todo rework into flushTransactions()
|
||||||
const s = useStore()
|
const s = useStore()
|
||||||
if( s.provider === null ) {
|
if( s.provider === null ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user