Skip to content

Commit 25062f8

Browse files
tx after coins
1 parent 49cd255 commit 25062f8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,24 +66,25 @@ export class Transaction extends BaseModel<ITransaction> {
6666
if (mintOps.length) {
6767
mintOps = partition(mintOps, mintOps.length / config.maxPoolSize);
6868
mintOps = mintOps.map((mintBatch: Array<any>) => CoinModel.collection.bulkWrite(mintBatch, { ordered: false }));
69-
await Promise.all(mintOps);
7069
}
7170
if (spendOps.length) {
7271
spendOps = partition(spendOps, spendOps.length / config.maxPoolSize);
7372
spendOps = spendOps.map((spendBatch: Array<any>) =>
7473
CoinModel.collection.bulkWrite(spendBatch, { ordered: false })
7574
);
7675
}
76+
const coinOps = mintOps.concat(spendOps);
77+
await Promise.all(coinOps);
7778

7879
let txs: Promise<BulkWriteOpResultObject>[] = [];
7980
if (mintOps) {
8081
let txOps = await this.addTransactions(params);
8182
logger.debug('Writing Transactions', txOps.length);
8283
const txBatches = partition(txOps, txOps.length / config.maxPoolSize);
83-
txs = txBatches.map((txBatch: Array<any>) => this.collection.bulkWrite(txBatch, { ordered: false }));
84+
txs = txBatches.map((txBatch: Array<any>) => this.collection.bulkWrite(txBatch, { ordered: false, j: false, w: 0 }));
8485
}
8586

86-
await Promise.all(spendOps.concat(txs));
87+
await Promise.all(txs);
8788
}
8889

8990
async addTransactions(params: {

0 commit comments

Comments
 (0)