remove console.log, fix null blocks

This commit is contained in:
Mononaut 2023-07-11 16:35:00 +09:00
parent 842ac8ce39
commit 7230b65dc3
No known key found for this signature in database
GPG key ID: A3F058E41374C04E
3 changed files with 10 additions and 7 deletions

View file

@ -142,7 +142,7 @@ export class BlockComponent implements OnInit, OnDestroy {
if (block?.extras?.reward != undefined) {
this.fees = block.extras.reward / 100000000 - this.blockSubsidy;
}
} else if (block.height === this.block.height) {
} else if (block.height === this.block?.height) {
this.block.stale = true;
this.block.canonical = block.id;
}

View file

@ -210,7 +210,7 @@ export class BlockchainBlocksComponent implements OnInit, OnChanges, OnDestroy {
if (this.chainTip == null) {
this.pendingMarkBlock = { animate, newBlockFromLeft };
}
const blockindex = this.blocks.findIndex((b) => { console.log(b); return b.height === this.markHeight });
const blockindex = this.blocks.findIndex((b) => b.height === this.markHeight);
if (blockindex > -1) {
if (!animate) {
this.arrowTransition = 'inherit';

View file

@ -5,7 +5,7 @@ import { IBackendInfo, MempoolBlock, MempoolBlockDelta, MempoolInfo, Recommended
import { BlockExtended, DifficultyAdjustment, MempoolPosition, OptimizedMempoolStats, RbfTree } from '../interfaces/node-api.interface';
import { Router, NavigationStart } from '@angular/router';
import { isPlatformBrowser } from '@angular/common';
import { map, scan, shareReplay } from 'rxjs/operators';
import { filter, map, scan, shareReplay } from 'rxjs/operators';
import { StorageService } from './storage.service';
export interface MarkBlockState {
@ -94,7 +94,8 @@ export class StateService {
networkChanged$ = new ReplaySubject<string>(1);
lightningChanged$ = new ReplaySubject<boolean>(1);
blocks$ = new BehaviorSubject<BlockExtended[]>([]);
blocksSubject$ = new BehaviorSubject<BlockExtended[]>([]);
blocks$: Observable<BlockExtended[]>;
transactions$ = new ReplaySubject<TransactionStripped>(6);
conversions$ = new ReplaySubject<any>(1);
bsqPrice$ = new ReplaySubject<number>(1);
@ -200,11 +201,13 @@ export class StateService {
this.networkChanged$.subscribe((network) => {
this.transactions$ = new ReplaySubject<TransactionStripped>(6);
this.blocks$ = new ReplaySubject<[BlockExtended, string]>(this.env.KEEP_BLOCKS_AMOUNT);
this.blocksSubject$ = new BehaviorSubject<BlockExtended[]>([]);
});
this.blockVSize = this.env.BLOCK_WEIGHT_UNITS / 4;
this.blocks$ = this.blocksSubject$.pipe(filter(blocks => blocks != null && blocks.length > 0));
const savedTimePreference = this.storageService.getValue('time-preference-ltr');
const rtlLanguage = (this.locale.startsWith('ar') || this.locale.startsWith('fa') || this.locale.startsWith('he'));
// default time direction is right-to-left, unless locale is a RTL language
@ -344,12 +347,12 @@ export class StateService {
resetBlocks(blocks: BlockExtended[]): void {
this.blocks = blocks.reverse();
this.blocks$.next(blocks);
this.blocksSubject$.next(blocks);
}
addBlock(block: BlockExtended): void {
this.blocks.unshift(block);
this.blocks = this.blocks.slice(0, this.env.KEEP_BLOCKS_AMOUNT);
this.blocks$.next(this.blocks);
this.blocksSubject$.next(this.blocks);
}
}