Skip to content

Commit 4fd7f32

Browse files
spends and txs can happen at the same time
1 parent 4172cce commit 4fd7f32

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/bitcore-node/src/models/transaction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ export class Transaction extends BaseModel<ITransaction> {
7070
spendOps = spendOps.map((spendBatch: Array<any>) =>
7171
CoinModel.collection.bulkWrite(spendBatch, { ordered: false })
7272
);
73-
await Promise.all(spendOps);
7473
}
7574

7675
let txOps = await this.addTransactions(params);
7776
logger.debug('Writing Transactions', txOps.length);
7877
const txBatches = partition(txOps, txOps.length / config.maxPoolSize);
7978
const txs = txBatches.map((txBatch: Array<any>) => this.collection.bulkWrite(txBatch, { ordered: false }));
80-
await Promise.all(txs);
79+
80+
await Promise.all(spendOps.concat(txs));
8181
}
8282

8383
async addTransactions(params: {

0 commit comments

Comments
 (0)