Merge pull request #1154 from nymkappa/bugfix/extreme-filter-only-mainnet
Only apply vbytes/sec cap on Bitcoin mainnet - Fix linter issues
This commit is contained in:
		
						commit
						3a67bc6425
					
				@ -169,15 +169,19 @@ export class StatisticsComponent implements OnInit {
 | 
				
			|||||||
   * All value higher that "median * capRatio" are capped
 | 
					   * All value higher that "median * capRatio" are capped
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  capExtremeVbytesValues() {
 | 
					  capExtremeVbytesValues() {
 | 
				
			||||||
 | 
					    if (this.stateService.network.length !== 0) {
 | 
				
			||||||
 | 
					      return; // Only cap on Bitcoin mainnet
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let capRatio = 10;
 | 
					    let capRatio = 10;
 | 
				
			||||||
    if (['1m', '3m',  '6m', '1y', '2y', '3y'].includes(this.graphWindowPreference)) {
 | 
					    if (['1m', '3m',  '6m', '1y', '2y', '3y'].includes(this.graphWindowPreference)) {
 | 
				
			||||||
      capRatio = 4;
 | 
					      capRatio = 4;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Find median value
 | 
					    // Find median value
 | 
				
			||||||
    let vBytes : number[] = [];
 | 
					    const vBytes : number[] = [];
 | 
				
			||||||
    for (let i = 0; i < this.mempoolStats.length; ++i) {
 | 
					    for (const stat of this.mempoolStats) {
 | 
				
			||||||
      vBytes.push(this.mempoolStats[i].vbytes_per_second);
 | 
					      vBytes.push(stat.vbytes_per_second);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    const sorted = vBytes.slice().sort((a, b) => a - b);
 | 
					    const sorted = vBytes.slice().sort((a, b) => a - b);
 | 
				
			||||||
    const middle = Math.floor(sorted.length / 2);
 | 
					    const middle = Math.floor(sorted.length / 2);
 | 
				
			||||||
@ -187,8 +191,8 @@ export class StatisticsComponent implements OnInit {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Cap
 | 
					    // Cap
 | 
				
			||||||
    for (let i = 0; i < this.mempoolStats.length; ++i) {
 | 
					    for (const stat of this.mempoolStats) {
 | 
				
			||||||
      this.mempoolStats[i].vbytes_per_second = Math.min(median * capRatio, this.mempoolStats[i].vbytes_per_second);
 | 
					      stat.vbytes_per_second = Math.min(median * capRatio, stat.vbytes_per_second);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user