Skip to content

Commit 9dac9f7

Browse files
author
Micah Riggan
committed
String wallets includes, and some logging help
1 parent 8e183c3 commit 9dac9f7

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,14 @@ export class InternalStateProvider implements CSP.IChainStateService {
220220
}
221221
let transactionStream = TransactionModel.getTransactions({ query });
222222
let listTransactionsStream = new ListTransactionsStream(wallet);
223-
transactionStream.pipe(listTransactionsStream).pipe(stream);
223+
let count = 0;
224+
let txcount = 0;
225+
transactionStream
226+
.on('data', () => txcount++)
227+
.pipe(listTransactionsStream)
228+
.on('data', () => count++)
229+
.on('finish', () => console.log(`txcount: ${txcount} count: ${count}`))
230+
.pipe(stream);
224231
}
225232

226233
async getWalletBalance(params: { wallet: IWallet }) {

packages/bitcore-node/src/providers/chain-state/internal/transforms.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ ListTransactionsStream.prototype._transform = function (transaction, enc, done)
2424

2525
transaction.inputs = inputs;
2626
transaction.outputs = outputs;
27-
var wallet = this.wallet._id;
27+
var wallet = this.wallet._id.toString();
2828
var totalInputs = transaction.inputs.reduce((total, input) => { return total + input.value; }, 0);
2929
var totalOutputs = transaction.outputs.reduce((total, output) => { return total + output.value; }, 0);
3030
var fee = totalInputs - totalOutputs;
31+
const stringifyWallets = (coin) => coin.wallets.map(w => w.toString());
3132

3233
for(let input of transaction.inputs) {
33-
if (input.wallets.includes(wallet)) {
34+
if (stringifyWallets(input).includes(wallet)) {
3435
self.push(JSON.stringify({
3536
txid: transaction.txid,
3637
category: 'send',
@@ -53,7 +54,7 @@ ListTransactionsStream.prototype._transform = function (transaction, enc, done)
5354
}
5455
}
5556
for(let output of transaction.outputs) {
56-
if (output.wallets.includes(wallet)) {
57+
if (stringifyWallets(output).includes(wallet)) {
5758
self.push(JSON.stringify({
5859
txid: transaction.txid,
5960
category: 'receive',

0 commit comments

Comments
 (0)