Merge branch 'turn-off-tx-saving' into next-merge
This commit is contained in:
commit
5a78d523a8
@ -6,7 +6,7 @@ const util = require('../../lib/util');
|
|||||||
const logger = require('../logger');
|
const logger = require('../logger');
|
||||||
const io = require('../api').io;
|
const io = require('../api').io;
|
||||||
|
|
||||||
const socketThrottle = 100;
|
const socketThrottle = 250;
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
|
|
||||||
function parse(entry, txs) {
|
function parse(entry, txs) {
|
||||||
@ -17,6 +17,8 @@ function parse(entry, txs) {
|
|||||||
|
|
||||||
if (counter % socketThrottle === 0) {
|
if (counter % socketThrottle === 0) {
|
||||||
|
|
||||||
|
counter = 0;
|
||||||
|
|
||||||
io.sockets.emit('tx', {
|
io.sockets.emit('tx', {
|
||||||
txid: txJSON.hash,
|
txid: txJSON.hash,
|
||||||
valueOut: tx.outputs.reduce((sum, tx) => {
|
valueOut: tx.outputs.reduce((sum, tx) => {
|
||||||
@ -28,46 +30,6 @@ function parse(entry, txs) {
|
|||||||
}, 0),
|
}, 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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user