Don't round signet difficulty in table and chart
This commit is contained in:
		
							parent
							
								
									a99b52a735
								
							
						
					
					
						commit
						eb71276948
					
				@ -4,6 +4,7 @@ import { map } from 'rxjs/operators';
 | 
				
			|||||||
import { ApiService } from 'src/app/services/api.service';
 | 
					import { ApiService } from 'src/app/services/api.service';
 | 
				
			||||||
import { formatNumber } from '@angular/common';
 | 
					import { formatNumber } from '@angular/common';
 | 
				
			||||||
import { selectPowerOfTen } from 'src/app/bitcoin.utils';
 | 
					import { selectPowerOfTen } from 'src/app/bitcoin.utils';
 | 
				
			||||||
 | 
					import { StateService } from 'src/app/services/state.service';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Component({
 | 
					@Component({
 | 
				
			||||||
  selector: 'app-difficulty-adjustments-table',
 | 
					  selector: 'app-difficulty-adjustments-table',
 | 
				
			||||||
@ -26,10 +27,16 @@ export class DifficultyAdjustmentsTable implements OnInit {
 | 
				
			|||||||
  constructor(
 | 
					  constructor(
 | 
				
			||||||
    @Inject(LOCALE_ID) public locale: string,
 | 
					    @Inject(LOCALE_ID) public locale: string,
 | 
				
			||||||
    private apiService: ApiService,
 | 
					    private apiService: ApiService,
 | 
				
			||||||
 | 
					    public stateService: StateService
 | 
				
			||||||
  ) {
 | 
					  ) {
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ngOnInit(): void {
 | 
					  ngOnInit(): void {
 | 
				
			||||||
 | 
					    let decimals = 2;
 | 
				
			||||||
 | 
					    if (this.stateService.network === 'signet') {
 | 
				
			||||||
 | 
					      decimals = 5;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this.hashrateObservable$ = this.apiService.getDifficultyAdjustments$('3m')
 | 
					    this.hashrateObservable$ = this.apiService.getDifficultyAdjustments$('3m')
 | 
				
			||||||
      .pipe(
 | 
					      .pipe(
 | 
				
			||||||
        map((response) => {
 | 
					        map((response) => {
 | 
				
			||||||
@ -43,7 +50,7 @@ export class DifficultyAdjustmentsTable implements OnInit {
 | 
				
			|||||||
              change: (adjustment[3] - 1) * 100,
 | 
					              change: (adjustment[3] - 1) * 100,
 | 
				
			||||||
              difficultyShorten: formatNumber(
 | 
					              difficultyShorten: formatNumber(
 | 
				
			||||||
                adjustment[2] / selectedPowerOfTen.divider,
 | 
					                adjustment[2] / selectedPowerOfTen.divider,
 | 
				
			||||||
                this.locale, '1.2-2') + selectedPowerOfTen.unit
 | 
					                this.locale, `1.${decimals}-${decimals}`) + selectedPowerOfTen.unit
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
          this.isLoading = false;
 | 
					          this.isLoading = false;
 | 
				
			||||||
 | 
				
			|||||||
@ -12,8 +12,11 @@
 | 
				
			|||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
      <div class="item">
 | 
					      <div class="item">
 | 
				
			||||||
        <h5 class="card-title" i18n="block.difficulty">Difficulty</h5>
 | 
					        <h5 class="card-title" i18n="block.difficulty">Difficulty</h5>
 | 
				
			||||||
        <p class="card-text">
 | 
					        <p class="card-text" *ngIf="network === 'signet'">
 | 
				
			||||||
          {{ hashrates.currentDifficulty | amountShortener }}
 | 
					          {{ hashrates.currentDifficulty | amountShortener : 5 }}
 | 
				
			||||||
 | 
					        </p>
 | 
				
			||||||
 | 
					        <p class="card-text" *ngIf="network !== 'signet'">
 | 
				
			||||||
 | 
					          {{ hashrates.currentDifficulty | amountShortener : 2 }}
 | 
				
			||||||
        </p>
 | 
					        </p>
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
				
			|||||||
@ -335,6 +335,9 @@ export class HashrateChartComponent implements OnInit {
 | 
				
			|||||||
          axisLabel: {
 | 
					          axisLabel: {
 | 
				
			||||||
            color: 'rgb(110, 112, 121)',
 | 
					            color: 'rgb(110, 112, 121)',
 | 
				
			||||||
            formatter: (val) => {
 | 
					            formatter: (val) => {
 | 
				
			||||||
 | 
					              if (this.stateService.network === 'signet') {
 | 
				
			||||||
 | 
					                return val;
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
              const selectedPowerOfTen: any = selectPowerOfTen(val);
 | 
					              const selectedPowerOfTen: any = selectPowerOfTen(val);
 | 
				
			||||||
              const newVal = Math.round(val / selectedPowerOfTen.divider);
 | 
					              const newVal = Math.round(val / selectedPowerOfTen.divider);
 | 
				
			||||||
              return `${newVal} ${selectedPowerOfTen.unit}`;
 | 
					              return `${newVal} ${selectedPowerOfTen.unit}`;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user