From 741a234c76e22221254e75e740373b325908278a Mon Sep 17 00:00:00 2001 From: tenthirtyone Date: Thu, 10 Aug 2017 23:40:38 -0400 Subject: [PATCH] Removing saving from tx parser. Only use for emitting block txs for now. Increase tx socket delay --- server/lib/parser/transaction.js | 44 +++----------------------------- 1 file changed, 3 insertions(+), 41 deletions(-) diff --git a/server/lib/parser/transaction.js b/server/lib/parser/transaction.js index 9bb4fa3..8549ffe 100644 --- a/server/lib/parser/transaction.js +++ b/server/lib/parser/transaction.js @@ -6,7 +6,7 @@ const util = require('../../lib/util'); const logger = require('../logger'); const io = require('../api').io; -const socketThrottle = 100; +const socketThrottle = 250; let counter = 0; function parse(entry, txs) { @@ -17,6 +17,8 @@ function parse(entry, txs) { if (counter % socketThrottle === 0) { + counter = 0; + io.sockets.emit('tx', { txid: txJSON.hash, valueOut: tx.outputs.reduce((sum, tx) => { @@ -28,46 +30,6 @@ function parse(entry, txs) { }, 0), }); } - - const t = new TxModel({ - hash: txJSON.hash, - witnessHash: txJSON.witnessHash, - fee: txJSON.fee, - rate: txJSON.rate, - ps: txJSON.ps, - height: entry.height, - block: util.revHex(entry.hash), - ts: entry.ts, - date: txJSON.date, - index: txJSON.index, - version: txJSON.version, - flag: txJSON.flag, - inputs: tx.inputs.map((input) => { - const inputJSON = input.toJSON(); - return new InputModel({ - prevout: inputJSON.prevout, - script: inputJSON.script, - witness: inputJSON.witness, - sequence: inputJSON.sequence, - address: inputJSON.address, - }); - }), - outputs: tx.outputs.map((output) => { - const outputJSON = output.toJSON(); - return new OutputModel({ - address: outputJSON.address, - script: outputJSON.script, - value: outputJSON.value, - }); - }), - lockTime: txJSON.locktime, - chain: config.bcoin.network, - }); - t.save((err) => { - if (err) { - logger.log('error', err.message); - } - }); }); }