mirror of
https://github.com/mempool/mempool.git
synced 2025-01-17 18:52:34 +01:00
parent
36e46249b5
commit
43dac03ec0
@ -4,7 +4,6 @@ import { Block } from 'src/app/interfaces/electrs.interface';
|
||||
import { StateService } from 'src/app/services/state.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { AudioService } from 'src/app/services/audio.service';
|
||||
import { KEEP_BLOCKS_AMOUNT } from 'src/app/app.constants';
|
||||
|
||||
@Component({
|
||||
selector: 'app-blockchain-blocks',
|
||||
@ -40,15 +39,14 @@ export class BlockchainBlocksComponent implements OnInit, OnDestroy {
|
||||
this.stateService.networkChanged$.subscribe((network) => this.network = network);
|
||||
|
||||
this.blocksSubscription = this.stateService.blocks$
|
||||
.subscribe(([block, txConfirmed]) => {
|
||||
const currentBlocksAmount = this.blocks.length;
|
||||
.subscribe(([block, txConfirmed, refilling]) => {
|
||||
if (this.blocks.some((b) => b.height === block.height)) {
|
||||
return;
|
||||
}
|
||||
this.blocks.unshift(block);
|
||||
this.blocks = this.blocks.slice(0, 8);
|
||||
|
||||
if (currentBlocksAmount === KEEP_BLOCKS_AMOUNT) {
|
||||
if (!refilling) {
|
||||
setTimeout(() => this.audioService.playSound('bright-harmony'));
|
||||
block.stage = block.matchRate >= 80 ? 1 : 2;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ export class StateService {
|
||||
latestBlockHeight = 0;
|
||||
|
||||
networkChanged$ = new ReplaySubject<string>(1);
|
||||
blocks$ = new ReplaySubject<[Block, boolean]>(KEEP_BLOCKS_AMOUNT);
|
||||
blocks$ = new ReplaySubject<[Block, boolean, boolean]>(KEEP_BLOCKS_AMOUNT);
|
||||
conversions$ = new ReplaySubject<any>(1);
|
||||
mempoolStats$ = new ReplaySubject<MemPoolState>(1);
|
||||
mempoolBlocks$ = new ReplaySubject<MempoolBlock[]>(1);
|
||||
|
@ -64,7 +64,7 @@ export class WebsocketService {
|
||||
blocks.forEach((block: Block) => {
|
||||
if (block.height > this.stateService.latestBlockHeight) {
|
||||
this.stateService.latestBlockHeight = block.height;
|
||||
this.stateService.blocks$.next([block, false]);
|
||||
this.stateService.blocks$.next([block, false, true]);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -76,7 +76,7 @@ export class WebsocketService {
|
||||
if (response.block) {
|
||||
if (response.block.height > this.stateService.latestBlockHeight) {
|
||||
this.stateService.latestBlockHeight = response.block.height;
|
||||
this.stateService.blocks$.next([response.block, !!response.txConfirmed]);
|
||||
this.stateService.blocks$.next([response.block, !!response.txConfirmed, false]);
|
||||
}
|
||||
|
||||
if (response.txConfirmed) {
|
||||
|
Loading…
Reference in New Issue
Block a user