1.0.9 Removing assertions in transction and p2p service

This commit is contained in:
Vivek Teega 2021-05-17 14:02:31 +05:30
parent 56e5cb1f25
commit 1efed08a39
2 changed files with 38 additions and 9 deletions

View File

@ -425,7 +425,12 @@ P2P.prototype._setListeners = function() {
P2P.prototype._setResourceFilter = function(filter) {
assert(filter && filter.startHash, 'A "startHash" field is required to retrieve headers or blocks');
// FLOSight Error Correction from RanchiMall 17th May 2021. removed the unhandled assert and replaced by looging of error
if (filter = false || filter.startHash = false) {
log.error('A "startHash" field is required to retrieve headers or blocks');
}
// assert(filter && filter.startHash, 'A "startHash" field is required to retrieve headers or blocks');
if (!filter.endHash) {
filter.endHash = 0;
}

View File

@ -7,6 +7,8 @@ var _ = require('lodash');
var async = require('async');
var assert = require('assert');
var LRU = require('lru-cache');
var index = require('../../');
var log = index.log;
function TransactionService(options) {
BaseService.call(this, options);
@ -184,8 +186,11 @@ TransactionService.prototype.setTxMetaInfo = function(tx, options, callback) {
var inputSatoshis = 0;
assert(tx.__inputValues.length === tx.inputs.length,
'Transaction Service: input values length is not the same as the number of inputs.');
// FLOSight Error Correction from RanchiMall 17th May 2021. removed the unhandled assert and replaced by looging of error
if (tx.__inputValues.length != tx.inputs.length) {
log.error('Transaction Service: input values length is not the same as the number of inputs.');
}
// assert(tx.__inputValues.length === tx.inputs.length, 'Transaction Service: input values length is not the same as the number of inputs.');
tx.__inputValues.forEach(function(val) {
@ -315,7 +320,11 @@ TransactionService.prototype._getInputValues = function(tx, options, callback) {
var output = tx.outputs[outputIndex];
assert(output, 'Expected an output, but did not get one for tx: ' + tx.txid() + ' outputIndex: ' + outputIndex);
// FLOSight Error Correction from RanchiMall 17th May 2021. removed the unhandled assert and replaced by looging of error
if (output = false) {
log.error('Expected an output, but did not get one for tx: ' + tx.txid() + ' outputIndex: ' + outputIndex);
}
// assert(output, 'Expected an output, but did not get one for tx: ' + tx.txid() + ' outputIndex: ' + outputIndex);
next(null, output.value);
}
@ -375,7 +384,11 @@ TransactionService.prototype.onBlock = function(block, callback) {
return callback(err);
}
assert(block.txs.length === operations.length, 'It seems we are not indexing the correct number of transactions.');
// FLOSight Error Correction from RanchiMall 17th May 2021. removed the unhandled assert and replaced by looging of error
if (block.txs.length != operations.length) {
log.error('It seems we are not indexing the correct number of transactions.');
}
// assert(block.txs.length === operations.length, 'It seems we are not indexing the correct number of transactions.');
callback(null, _.flattenDeep(operations));
});
@ -477,19 +490,30 @@ TransactionService.prototype._processTransaction = function(tx, opts, callback)
return callback(err);
}
assert(inputValues && inputValues.length === tx.inputs.length,
'Input values missing from tx.');
// FLOSight Error Correction from RanchiMall 17th May 2021. removed the unhandled assert and replaced by looging of error
if (inputValues = false || inputValues.length != tx.inputs.length) {
log.error('Input values missing from tx.');
}
// assert(inputValues && inputValues.length === tx.inputs.length, 'Input values missing from tx.');
// inputValues
tx.__inputValues = inputValues;
// timestamp
tx.__timestamp = self._getBlockTimestamp(opts.block.rhash());
assert(tx.__timestamp, 'Timestamp is required when saving a transaction.');
// FLOSight Error Correction from RanchiMall 17th May 2021. removed the unhandled assert and replaced by looging of error
if (tx.__timestamp = false) {
log.error('Timestamp is required when saving a transaction.');
}
// assert(tx.__timestamp, 'Timestamp is required when saving a transaction.');
// height
tx.__height = opts.block.__height;
assert(tx.__height, 'Block height is required when saving a trasnaction.');
// FLOSight Error Correction from RanchiMall 17th May 2021. removed the unhandled assert and replaced by looging of error
if (tx.__height = false) {
log.error('Block height is required when saving a trasnaction.');
}
//assert(tx.__height, 'Block height is required when saving a trasnaction.');
// block hash
tx.__blockhash = opts.block.rhash();