Skip to content

Commit a051f93

Browse files
author
Micah Riggan
committed
Merge branch 'pruneMempool' of github.com:nitsujlangston/bitcore into pruneMempool
2 parents 6b492b3 + 0a947c9 commit a051f93

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ class Coin extends BaseModel<ICoin> {
6868
}
6969
);
7070
this.collection.createIndex({ address: 1 }, { background: true });
71-
this.collection.createIndex({ mintHeight: 1, chain: 1, network: 1 }, { background: true });
71+
this.collection.createIndex({ chain: 1, network: 1, mintHeight: 1 }, { background: true });
7272
this.collection.createIndex({ spentTxid: 1 }, { background: true, sparse: true });
73-
this.collection.createIndex({ spentHeight: 1, chain: 1, network: 1 }, { background: true });
74-
this.collection.createIndex({ wallets: 1, spentHeight: 1 }, { background: true, sparse: true });
73+
this.collection.createIndex({ chain: 1, network: 1, spentHeight: 1 }, { background: true });
74+
this.collection.createIndex({ wallets: 1, spentHeight: 1, value: 1 }, { background: true, partialFilterExpression: { 'wallets.0': { $exists: true } } });
7575
}
7676

7777
getBalance(params: { query: any }) {
@@ -83,6 +83,7 @@ class Coin extends BaseModel<ICoin> {
8383
return this.collection
8484
.aggregate<{ balance: number }>([
8585
{ $match: query },
86+
{ $project: { value: 1, _id: 0 }},
8687
{
8788
$group: {
8889
_id: null,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ export class Transaction extends BaseModel<ITransaction> {
4040

4141
onConnect() {
4242
this.collection.createIndex({ txid: 1 }, { background: true });
43-
this.collection.createIndex({ blockHeight: 1, chain: 1, network: 1 }, { background: true });
43+
this.collection.createIndex({ chain: 1, network: 1, blockHeight: 1 }, { background: true });
4444
this.collection.createIndex({ blockHash: 1 }, { background: true });
45-
this.collection.createIndex({ blockTimeNormalized: 1, chain: 1, network: 1 }, { background: true });
45+
this.collection.createIndex({ chain: 1, network: 1, blockTimeNormalized: 1 }, { background: true });
4646
this.collection.createIndex({ wallets: 1, blockTimeNormalized: 1 }, { background: true, partialFilterExpression: { 'wallets.0': { $exists: true } } });
4747
this.collection.createIndex({ wallets: 1, blockHeight: 1 }, { background: true, partialFilterExpression: { 'wallets.0': { $exists: true } } });
4848
}

packages/bitcore-node/src/providers/chain-state/internal/internal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,13 @@ export class InternalStateProvider implements CSP.IChainStateService {
324324
}
325325

326326
async getWalletBalance(params: CSP.GetWalletBalanceParams) {
327-
let query = { wallets: params.wallet._id };
327+
let query = { wallets: params.wallet._id, 'wallets.0': { $exists: true } };
328328
return CoinModel.getBalance({ query });
329329
}
330330

331331
async streamWalletUtxos(params: CSP.StreamWalletUtxosParams) {
332332
const { wallet, limit, args = {}, stream } = params;
333-
let query: any = { wallets: wallet._id, mintHeight: { $gt: SpentHeightIndicators.conflicting } };
333+
let query: any = { wallets: wallet._id, 'wallets.0': { $exists: true }, mintHeight: { $gt: SpentHeightIndicators.conflicting } };
334334
if (args.includeSpent !== 'true') {
335335
query.spentHeight = { $lt: SpentHeightIndicators.pending };
336336
}

0 commit comments

Comments
 (0)