mirror of
https://github.com/mempool/mempool.git
synced 2025-01-18 05:12:35 +01:00
Fixed sorting issue that caused the median calculation bug.
This commit is contained in:
parent
72658c19f6
commit
e84ec7dd86
@ -92,7 +92,6 @@ class Blocks {
|
||||
private median(numbers: number[]) {
|
||||
let medianNr = 0;
|
||||
const numsLen = numbers.length;
|
||||
numbers.sort();
|
||||
if (numsLen % 2 === 0) {
|
||||
medianNr = (numbers[numsLen / 2 - 1] + numbers[numsLen / 2]) / 2;
|
||||
} else {
|
||||
|
@ -47,16 +47,14 @@ class MempoolBlocks {
|
||||
}
|
||||
|
||||
private dataToMempoolBlocks(transactions: TransactionExtended[], blockSize: number, blockVSize: number, blocksIndex: number): MempoolBlock {
|
||||
let rangeLength = 3;
|
||||
let rangeLength = 4;
|
||||
if (blocksIndex === 0) {
|
||||
rangeLength = 8;
|
||||
}
|
||||
if (transactions.length > 4000) {
|
||||
rangeLength = 5;
|
||||
rangeLength = 6;
|
||||
} else if (transactions.length > 10000) {
|
||||
rangeLength = 8;
|
||||
} else if (transactions.length > 25000) {
|
||||
rangeLength = 10;
|
||||
}
|
||||
return {
|
||||
blockSize: blockSize,
|
||||
@ -71,7 +69,6 @@ class MempoolBlocks {
|
||||
private median(numbers: number[]) {
|
||||
let medianNr = 0;
|
||||
const numsLen = numbers.length;
|
||||
numbers.sort();
|
||||
if (numsLen % 2 === 0) {
|
||||
medianNr = (numbers[numsLen / 2 - 1] + numbers[numsLen / 2]) / 2;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user