diff --git a/backend/src/api/blocks.ts b/backend/src/api/blocks.ts index c406ae803..1452b6fc8 100644 --- a/backend/src/api/blocks.ts +++ b/backend/src/api/blocks.ts @@ -198,7 +198,7 @@ class Blocks { logger.info(`Indexing blocks from #${currentBlockHeight} to #${lastBlockToIndex}`); const chunkSize = 10000; - let totaIndexed = 0; + let totaIndexed = await blocksRepository.$blockCount(null, null); let indexedThisRun = 0; while (currentBlockHeight >= lastBlockToIndex) { const endBlock = Math.max(0, lastBlockToIndex, currentBlockHeight - chunkSize + 1); @@ -208,11 +208,9 @@ class Blocks { if (missingBlockHeights.length <= 0) { logger.debug(`No missing blocks between #${currentBlockHeight} to #${endBlock}`); currentBlockHeight -= chunkSize; - totaIndexed += chunkSize; continue; } - totaIndexed += chunkSize - missingBlockHeights.length; logger.debug(`Indexing ${missingBlockHeights.length} blocks from #${currentBlockHeight} to #${endBlock}`); for (const blockHeight of missingBlockHeights) { @@ -220,7 +218,8 @@ class Blocks { break; } try { - if (totaIndexed % 100 === 0 || blockHeight === lastBlockToIndex) { + ++indexedThisRun; + if (++totaIndexed % 100 === 0 || blockHeight === lastBlockToIndex) { const elapsedSeconds = Math.max(1, Math.round((new Date().getTime() / 1000) - startedAt)); const blockPerSeconds = Math.max(1, Math.round(indexedThisRun / elapsedSeconds)); const progress = Math.round(totaIndexed / indexingBlockAmount * 100); @@ -232,8 +231,6 @@ class Blocks { const transactions = await this.$getTransactionsExtended(blockHash, block.height, true, true); const blockExtended = await this.$getBlockExtended(block, transactions); await blocksRepository.$saveBlockInDatabase(blockExtended); - ++totaIndexed; - ++indexedThisRun; } catch (e) { logger.err(`Something went wrong while indexing blocks.` + e); } diff --git a/frontend/src/app/app-routing.module.ts b/frontend/src/app/app-routing.module.ts index 6ce39b1d2..f0aa73e3d 100644 --- a/frontend/src/app/app-routing.module.ts +++ b/frontend/src/app/app-routing.module.ts @@ -27,6 +27,7 @@ import { AssetGroupComponent } from './components/assets/asset-group/asset-group import { AssetsFeaturedComponent } from './components/assets/assets-featured/assets-featured.component'; import { AssetsComponent } from './components/assets/assets.component'; import { PoolComponent } from './components/pool/pool.component'; +import { MiningDashboardComponent } from './components/mining-dashboard/mining-dashboard.component'; import { DifficultyChartComponent } from './components/difficulty-chart/difficulty-chart.component'; let routes: Routes = [ @@ -58,6 +59,10 @@ let routes: Routes = [ path: 'mempool-block/:id', component: MempoolBlockComponent }, + { + path: 'mining', + component: MiningDashboardComponent, + }, ], }, { @@ -154,6 +159,10 @@ let routes: Routes = [ path: 'mempool-block/:id', component: MempoolBlockComponent }, + { + path: 'mining', + component: MiningDashboardComponent, + }, ], }, { @@ -244,6 +253,10 @@ let routes: Routes = [ path: 'mempool-block/:id', component: MempoolBlockComponent }, + { + path: 'mining', + component: MiningDashboardComponent, + }, ], }, { diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index 15bebd033..677d88d6e 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -68,6 +68,7 @@ import { PushTransactionComponent } from './components/push-transaction/push-tra import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { AssetsFeaturedComponent } from './components/assets/assets-featured/assets-featured.component'; import { AssetGroupComponent } from './components/assets/asset-group/asset-group.component'; +import { MiningDashboardComponent } from './components/mining-dashboard/mining-dashboard.component'; import { DifficultyChartComponent } from './components/difficulty-chart/difficulty-chart.component'; @NgModule({ @@ -119,6 +120,7 @@ import { DifficultyChartComponent } from './components/difficulty-chart/difficul AssetsNavComponent, AssetsFeaturedComponent, AssetGroupComponent, + MiningDashboardComponent, DifficultyChartComponent, ], imports: [ diff --git a/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.html b/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.html index 50fd82b09..1914b5d08 100644 --- a/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.html +++ b/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.html @@ -21,9 +21,13 @@