aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2018-09-17 02:27:35 +0000
committerAdam Soltys <[email protected]>2018-09-17 02:27:35 +0000
commitb824558eb8aa28d43078e7ff02e6cb1bc2fa5881 (patch)
tree1c00289dfaa3317578899d818ad2e81850103b3e
parent9b5ed5e197c6c08cd7cce7e2d2c7d37c835f1aec (diff)
downloadcoinos-server-b824558eb8aa28d43078e7ff02e6cb1bc2fa5881.tar.gz
coinos-server-b824558eb8aa28d43078e7ff02e6cb1bc2fa5881.zip
separate zmq sockets for blocks and tx's
-rw-r--r--index.js22
1 files changed, 16 insertions, 6 deletions
diff --git a/index.js b/index.js
index c009343b..5593ddab 100644
--- a/index.js
+++ b/index.js
@@ -106,10 +106,13 @@ const l = console.log
const invoicesb = lnb.subscribeInvoices({})
invoicesb.on('data', handlePayment)
- const zmqSock = zmq.socket('sub')
- zmqSock.connect(config.bitcoin.zmq)
- zmqSock.subscribe('rawblock')
- zmqSock.subscribe('rawtx')
+ const zmqRawBlock = zmq.socket('sub')
+ zmqRawBlock.connect(config.bitcoin.zmqrawblock)
+ zmqRawBlock.subscribe('rawblock')
+
+ const zmqRawTx = zmq.socket('sub')
+ zmqRawTx.connect(config.bitcoin.zmqrawtx)
+ zmqRawTx.subscribe('rawtx')
const addresses = {}
await db.User.findAll({
@@ -120,7 +123,7 @@ const l = console.log
attributes: ['hash']
})).map(p => p.hash)
- zmqSock.on('message', async (topic, message, sequence) => {
+ zmqRawTx.on('message', async (topic, message, sequence) => {
topic = topic.toString('utf8')
message = message.toString('hex')
@@ -170,7 +173,14 @@ const l = console.log
break
}
+ }
+ })
+ zmqRawBlock.on('message', async (topic, message, sequence) => {
+ topic = topic.toString('utf8')
+ message = message.toString('hex')
+
+ switch (topic) {
case 'rawblock': {
let block = bitcoin.Block.fromHex(message)
l('block', block.getHash().toString('hex'))
@@ -237,7 +247,7 @@ const l = console.log
l('channel error', peer, err)
let msg = err.message
- if (msg.startsWith('Multiple')) {
+ if (msg.startsWith('Multiple') || msg.startsWith('You gave')) {
busypeers.push(peer)
peer = lna.channelpeers.find(p => !busypeers.includes(p))
if (peer) {