diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 9173f8827..0cd95e568 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -1,7 +1,10 @@ name: Cypress Tests -on: [push, pull_request] - +on: + push: + branches: + - master + pull_request: jobs: cypress: runs-on: ${{ matrix.os }} @@ -24,6 +27,7 @@ jobs: - name: ${{ matrix.browser }} browser tests (Mempool) uses: cypress-io/github-action@v2 with: + tag: ${{ github.event_name }} working-directory: frontend build: npm run config:defaults:mempool start: npm run start:local-staging @@ -39,6 +43,7 @@ jobs: browser: ${{ matrix.browser }} ci-build-id: '${{ github.sha }}-${{ github.workflow }}-${{ github.event_name }}' env: + COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }} CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }} @@ -47,6 +52,7 @@ jobs: uses: cypress-io/github-action@v2 if: always() with: + tag: ${{ github.event_name }} working-directory: frontend build: npm run config:defaults:liquid start: npm run start:local-staging @@ -61,6 +67,7 @@ jobs: browser: ${{ matrix.browser }} ci-build-id: '${{ github.sha }}-${{ github.workflow }}-${{ github.event_name }}' env: + COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }} CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }} @@ -69,6 +76,7 @@ jobs: uses: cypress-io/github-action@v2 if: always() with: + tag: ${{ github.event_name }} working-directory: frontend build: npm run config:defaults:bisq start: npm run start:local-staging @@ -81,6 +89,7 @@ jobs: browser: ${{ matrix.browser }} ci-build-id: '${{ github.sha }}-${{ github.workflow }}-${{ github.event_name }}' env: + COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }} CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }} diff --git a/README.md b/README.md index 85cadb729..af4ae224f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# The Mempool Open Source Projectâ„¢ +# The Mempool Open Source Projectâ„¢ [![mempool](https://img.shields.io/endpoint?url=https://dashboard.cypress.io/badge/simple/ry4br7/master&style=flat-square)](https://dashboard.cypress.io/projects/ry4br7/runs) Mempool is the fully featured visualizer, explorer, and API service running on [mempool.space](https://mempool.space/), an open source project developed and operated for the benefit of the Bitcoin community, with a focus on the emerging transaction fee market to help our transition into a multi-layer ecosystem. diff --git a/backend/src/api/blocks.ts b/backend/src/api/blocks.ts index cd72d91e0..198f2a204 100644 --- a/backend/src/api/blocks.ts +++ b/backend/src/api/blocks.ts @@ -301,8 +301,6 @@ class Blocks { if (memPool.isInSync()) { diskCache.$saveCacheToDisk(); } - - return; } } diff --git a/frontend/.gitignore b/frontend/.gitignore index 64b7777ea..789881ddd 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -53,6 +53,7 @@ src/resources/assets.minimal.json src/resources/assets-testnet.json src/resources/assets-testnet.minimal.json src/resources/pools.json +src/resources/mining-pools/* # environment config mempool-frontend-config.json diff --git a/frontend/src/app/components/television/television.component.html b/frontend/src/app/components/television/television.component.html index c9caa54ef..7da6e2d38 100644 --- a/frontend/src/app/components/television/television.component.html +++ b/frontend/src/app/components/television/television.component.html @@ -7,7 +7,7 @@ [height]="600" [left]="60" [right]="10" - [data]="mempoolStats && mempoolStats.length ? mempoolStats : null" + [data]="statsSubscription$ | async" [showZoom]="false" > diff --git a/frontend/src/app/components/television/television.component.ts b/frontend/src/app/components/television/television.component.ts index ae5d9abfd..3c0c88ec8 100644 --- a/frontend/src/app/components/television/television.component.ts +++ b/frontend/src/app/components/television/television.component.ts @@ -4,39 +4,70 @@ import { OptimizedMempoolStats } from '../../interfaces/node-api.interface'; import { StateService } from 'src/app/services/state.service'; import { ApiService } from 'src/app/services/api.service'; import { SeoService } from 'src/app/services/seo.service'; -import { Observable } from 'rxjs'; +import { ActivatedRoute } from '@angular/router'; +import { map, scan, startWith, switchMap, tap } from 'rxjs/operators'; +import { interval, merge, Observable } from 'rxjs'; +import { ChangeDetectionStrategy } from '@angular/core'; @Component({ selector: 'app-television', templateUrl: './television.component.html', - styleUrls: ['./television.component.scss'] + styleUrls: ['./television.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush }) export class TelevisionComponent implements OnInit { mempoolStats: OptimizedMempoolStats[] = []; - mempoolVsizeFeesData: any; + statsSubscription$: Observable; + fragment: string; constructor( private websocketService: WebsocketService, private apiService: ApiService, private stateService: StateService, private seoService: SeoService, + private route: ActivatedRoute ) { } + refreshStats(time: number, fn: Observable) { + return interval(time).pipe(startWith(0), switchMap(() => fn)); + } + ngOnInit() { this.seoService.setTitle($localize`:@@46ce8155c9ab953edeec97e8950b5a21e67d7c4e:TV view`); this.websocketService.want(['blocks', 'live-2h-chart', 'mempool-blocks']); - this.apiService.list2HStatistics$() - .subscribe((mempoolStats) => { - this.mempoolStats = mempoolStats; - }); - - this.stateService.live2Chart$ - .subscribe((mempoolStats) => { - this.mempoolStats.unshift(mempoolStats); - this.mempoolStats = this.mempoolStats.slice(0, this.mempoolStats.length - 1); - }); + this.statsSubscription$ = merge( + this.stateService.live2Chart$.pipe(map(stats => [stats])), + this.route.fragment + .pipe( + tap(fragment => { this.fragment = fragment ?? '2h'; }), + switchMap((fragment) => { + const minute = 60000; const hour = 3600000; + switch (fragment) { + case '24h': return this.apiService.list24HStatistics$(); + case '1w': return this.refreshStats(5 * minute, this.apiService.list1WStatistics$()); + case '1m': return this.refreshStats(30 * minute, this.apiService.list1MStatistics$()); + case '3m': return this.refreshStats(2 * hour, this.apiService.list3MStatistics$()); + case '6m': return this.refreshStats(3 * hour, this.apiService.list6MStatistics$()); + case '1y': return this.refreshStats(8 * hour, this.apiService.list1YStatistics$()); + case '2y': return this.refreshStats(8 * hour, this.apiService.list2YStatistics$()); + case '3y': return this.refreshStats(12 * hour, this.apiService.list3YStatistics$()); + default /* 2h */: return this.apiService.list2HStatistics$(); + } + }) + ) + ) + .pipe( + scan((mempoolStats, newStats) => { + if (newStats.length > 1) { + mempoolStats = newStats; + } else if (['2h', '24h'].includes(this.fragment)) { + mempoolStats.unshift(newStats[0]); + mempoolStats = mempoolStats.slice(0, mempoolStats.length - 1); + } + return mempoolStats; + }) + ); } - } diff --git a/frontend/sync-assets.js b/frontend/sync-assets.js index b1dc4090d..c37b987a2 100644 --- a/frontend/sync-assets.js +++ b/frontend/sync-assets.js @@ -33,6 +33,35 @@ function download(filename, url) { }); } +function downloadMiningPoolLogos() { + const options = { + host: 'api.github.com', + path: '/repos/mempool/mining-pools/contents/', + method: 'GET', + headers: {'user-agent': 'node.js'} + }; + + https.get(options, (response) => { + let chunks_of_data = []; + + response.on('data', (fragments) => { + chunks_of_data.push(fragments); + }); + + response.on('end', () => { + let response_body = Buffer.concat(chunks_of_data); + const poolLogos = JSON.parse(response_body.toString()); + for (const poolLogo of poolLogos) { + download(`${PATH}/mining-pools/${poolLogo.name}`, poolLogo.download_url); + } + }); + + response.on('error', (error) => { + throw new Error(error); + }); + }) +} + const poolsJsonUrl = 'https://raw.githubusercontent.com/btccom/Blockchain-Known-Pools/master/pools.json'; let assetsJsonUrl = 'https://raw.githubusercontent.com/mempool/asset_registry_db/master/index.json'; let assetsMinimalJsonUrl = 'https://raw.githubusercontent.com/mempool/asset_registry_db/master/index.minimal.json'; @@ -55,4 +84,5 @@ console.log('Downloading testnet assets'); download(PATH + 'assets-testnet.json', testnetAssetsJsonUrl); console.log('Downloading testnet assets minimal'); download(PATH + 'assets-testnet.minimal.json', testnetAssetsMinimalJsonUrl); - +console.log('Downloading mining pool logos'); +downloadMiningPoolLogos();