Crash fix.
This commit is contained in:
parent
0b74e6cba8
commit
5cbbf5a186
@ -75,7 +75,7 @@ class Blocks {
|
|||||||
block.reward = transactions[0].vout.reduce((acc, curr) => acc + curr.value, 0);
|
block.reward = transactions[0].vout.reduce((acc, curr) => acc + curr.value, 0);
|
||||||
transactions.sort((a, b) => b.feePerVsize - a.feePerVsize);
|
transactions.sort((a, b) => b.feePerVsize - a.feePerVsize);
|
||||||
block.medianFee = transactions.length > 1 ? Common.median(transactions.map((tx) => tx.feePerVsize)) : 0;
|
block.medianFee = transactions.length > 1 ? Common.median(transactions.map((tx) => tx.feePerVsize)) : 0;
|
||||||
block.feeRange = transactions.length > 1 ? Common.getFeesInRange(transactions, 8) : [0, 0];
|
block.feeRange = transactions.length > 1 ? Common.getFeesInRange(transactions, 8, 1) : [0, 0];
|
||||||
block.coinbaseTx = this.stripCoinbaseTransaction(transactions[0]);
|
block.coinbaseTx = this.stripCoinbaseTransaction(transactions[0]);
|
||||||
|
|
||||||
this.blocks.push(block);
|
this.blocks.push(block);
|
||||||
|
@ -12,7 +12,7 @@ export class Common {
|
|||||||
return medianNr;
|
return medianNr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static getFeesInRange(transactions: TransactionExtended[], rangeLength: number) {
|
static getFeesInRange(transactions: TransactionExtended[], rangeLength: number, lastindex = 0) {
|
||||||
const arr = [transactions[transactions.length - 1].feePerVsize];
|
const arr = [transactions[transactions.length - 1].feePerVsize];
|
||||||
const chunk = 1 / (rangeLength - 1);
|
const chunk = 1 / (rangeLength - 1);
|
||||||
let itemsToAdd = rangeLength - 2;
|
let itemsToAdd = rangeLength - 2;
|
||||||
@ -22,7 +22,7 @@ export class Common {
|
|||||||
itemsToAdd--;
|
itemsToAdd--;
|
||||||
}
|
}
|
||||||
|
|
||||||
arr.push(transactions[1].feePerVsize);
|
arr.push(transactions[lastindex].feePerVsize);
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user