Skip to content

Commit

Permalink
Merge pull request bitpay#2339 from msalcala11/fix/p2p-transaction-ev…
Browse files Browse the repository at this point in the history
…ents

Ensure all incoming p2p transactions are broadcasted to socket clients
  • Loading branch information
matiu authored Aug 21, 2019
2 parents 33d11f7 + 3df964a commit 0cfddf9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/bitcore-node/src/services/p2p.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class P2pManager {
for (let chainNetwork of Config.chainNetworks()) {
const { chain, network } = chainNetwork;
const chainConfig = Config.chainConfig(chainNetwork);
if (chainConfig.chainSource && chainConfig.chainSource !== 'p2p' || chainConfig.disabled) {
if ((chainConfig.chainSource && chainConfig.chainSource !== 'p2p') || chainConfig.disabled) {
continue;
}
const p2pWorker = new P2pWorker({
Expand Down Expand Up @@ -195,7 +195,7 @@ export class P2pWorker {
});

this.pool.on('peerinv', (peer, message) => {
if (this.isSyncingNode && !this.isSyncing) {
if (this.isSyncingNode) {
const filtered = message.inventory.filter(inv => {
const hash = this.bitcoreLib.encoding
.BufferReader(inv.hash)
Expand Down
8 changes: 4 additions & 4 deletions packages/bitcore-node/src/services/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ export class SocketService {
if (this.io) {
const { chain, network } = tx;
const sanitizedTx = SanitizeWallet(tx);
this.io.volatile.sockets.in(`/${chain}/${network}/inv`).emit('tx', sanitizedTx);
this.io.sockets.in(`/${chain}/${network}/inv`).emit('tx', sanitizedTx);
}
});

this.eventService.blockEvent.on('block', (block: IEvent.BlockEvent) => {
if (this.io) {
const { chain, network } = block;
this.io.volatile.sockets.in(`/${chain}/${network}/inv`).emit('block', block);
this.io.sockets.in(`/${chain}/${network}/inv`).emit('block', block);
}
});

Expand All @@ -91,8 +91,8 @@ export class SocketService {
const { coin, address } = addressCoin;
const { chain, network } = coin;
const sanitizedCoin = SanitizeWallet(coin);
this.io.volatile.sockets.in(`/${chain}/${network}/address`).emit(address, sanitizedCoin);
this.io.volatile.sockets.in(`/${chain}/${network}/inv`).emit('coin', sanitizedCoin);
this.io.sockets.in(`/${chain}/${network}/address`).emit(address, sanitizedCoin);
this.io.sockets.in(`/${chain}/${network}/inv`).emit('coin', sanitizedCoin);
}
});
}
Expand Down

0 comments on commit 0cfddf9

Please sign in to comment.