fix mutex
This commit is contained in:
parent
af7c597af9
commit
f6a4e93a23
@ -96,7 +96,7 @@ class Transaction {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
async _execute() {
|
async _execute() {
|
||||||
await this.manager._mutex.acquire()
|
const mutexRelease = await this.manager._mutex.acquire()
|
||||||
try {
|
try {
|
||||||
await this._prepare()
|
await this._prepare()
|
||||||
await this._send()
|
await this._send()
|
||||||
@ -105,7 +105,7 @@ class Transaction {
|
|||||||
this.manager._nonce = this.tx.nonce + 1
|
this.manager._nonce = this.tx.nonce + 1
|
||||||
return receipt
|
return receipt
|
||||||
} finally {
|
} finally {
|
||||||
this.manager._mutex.release()
|
mutexRelease()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,5 +101,23 @@ describe('TxManager', () => {
|
|||||||
|
|
||||||
console.log('receipt', receipt)
|
console.log('receipt', receipt)
|
||||||
})
|
})
|
||||||
|
it.only('should send multiple txs', async () => {
|
||||||
|
const genTx = value => ({
|
||||||
|
value,
|
||||||
|
to: '0x0039F22efB07A647557C7C5d17854CFD6D489eF3',
|
||||||
|
})
|
||||||
|
await Promise.all([
|
||||||
|
manager.createTx(genTx(1)).send(),
|
||||||
|
manager.createTx(genTx(2)).send(),
|
||||||
|
manager.createTx(genTx(3)).send(),
|
||||||
|
manager.createTx(genTx(4)).send(),
|
||||||
|
manager.createTx(genTx(5)).send(),
|
||||||
|
manager.createTx(genTx(6)).send(),
|
||||||
|
manager.createTx(genTx(7)).send(),
|
||||||
|
manager.createTx(genTx(8)).send(),
|
||||||
|
manager.createTx(genTx(9)).send(),
|
||||||
|
manager.createTx(genTx(10)).send(),
|
||||||
|
])
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user