mirror of
https://github.com/mempool/mempool.git
synced 2025-01-19 05:34:03 +01:00
Provide a way to completely disable block indexing and mining menu
This commit is contained in:
parent
02523f574d
commit
ca766bf40d
@ -116,10 +116,7 @@ class Blocks {
|
||||
blockExtended.extras.feeRange = transactionsTmp.length > 0 ?
|
||||
Common.getFeesInRange(transactionsTmp, 8) : [0, 0];
|
||||
|
||||
const indexingAvailable =
|
||||
['mainnet', 'testnet', 'signet'].includes(config.MEMPOOL.NETWORK) &&
|
||||
config.DATABASE.ENABLED === true;
|
||||
if (indexingAvailable) {
|
||||
if (Common.indexingEnabled()) {
|
||||
let pool: PoolTag;
|
||||
if (blockExtended.extras?.coinbaseTx !== undefined) {
|
||||
pool = await this.$findBlockMiner(blockExtended.extras?.coinbaseTx);
|
||||
@ -173,11 +170,9 @@ class Blocks {
|
||||
* Index all blocks metadata for the mining dashboard
|
||||
*/
|
||||
public async $generateBlockDatabase() {
|
||||
if (['mainnet', 'testnet', 'signet'].includes(config.MEMPOOL.NETWORK) === false || // Bitcoin only
|
||||
config.MEMPOOL.INDEXING_BLOCKS_AMOUNT === 0 || // Indexing of older blocks must be enabled
|
||||
memPool.hasPriority() || // We sync the mempool first
|
||||
this.blockIndexingStarted === true || // Indexing must not already be in progress
|
||||
config.DATABASE.ENABLED === false
|
||||
if (this.blockIndexingStarted === true ||
|
||||
!Common.indexingEnabled() ||
|
||||
memPool.hasPriority()
|
||||
) {
|
||||
return;
|
||||
}
|
||||
@ -293,10 +288,7 @@ class Blocks {
|
||||
const transactions = await this.$getTransactionsExtended(blockHash, block.height, false);
|
||||
const blockExtended: BlockExtended = await this.$getBlockExtended(block, transactions);
|
||||
|
||||
const indexingAvailable =
|
||||
['mainnet', 'testnet', 'signet'].includes(config.MEMPOOL.NETWORK) &&
|
||||
config.DATABASE.ENABLED === true;
|
||||
if (indexingAvailable) {
|
||||
if (Common.indexingEnabled()) {
|
||||
await blocksRepository.$saveBlockInDatabase(blockExtended);
|
||||
}
|
||||
|
||||
@ -340,10 +332,6 @@ class Blocks {
|
||||
}
|
||||
|
||||
public async $getBlocksExtras(fromHeight: number): Promise<BlockExtended[]> {
|
||||
const indexingAvailable =
|
||||
['mainnet', 'testnet', 'signet'].includes(config.MEMPOOL.NETWORK) &&
|
||||
config.DATABASE.ENABLED === true;
|
||||
|
||||
try {
|
||||
loadingIndicators.setProgress('blocks', 0);
|
||||
|
||||
@ -366,7 +354,7 @@ class Blocks {
|
||||
let nextHash = startFromHash;
|
||||
for (let i = 0; i < 10 && currentHeight >= 0; i++) {
|
||||
let block = this.getBlocks().find((b) => b.height === currentHeight);
|
||||
if (!block && indexingAvailable) {
|
||||
if (!block && Common.indexingEnabled()) {
|
||||
block = this.prepareBlock(await this.$indexBlock(currentHeight));
|
||||
} else if (!block) {
|
||||
block = this.prepareBlock(await bitcoinApi.$getBlock(nextHash));
|
||||
|
@ -154,4 +154,12 @@ export class Common {
|
||||
});
|
||||
return parents;
|
||||
}
|
||||
|
||||
static indexingEnabled(): boolean {
|
||||
return (
|
||||
['mainnet', 'testnet', 'signet'].includes(config.MEMPOOL.NETWORK) &&
|
||||
config.DATABASE.ENABLED === true &&
|
||||
config.MEMPOOL.INDEXING_BLOCKS_AMOUNT != 0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -15,5 +15,6 @@
|
||||
"BASE_MODULE": "mempool",
|
||||
"MEMPOOL_WEBSITE_URL": "https://mempool.space",
|
||||
"LIQUID_WEBSITE_URL": "https://liquid.network",
|
||||
"BISQ_WEBSITE_URL": "https://bisq.markets"
|
||||
"BISQ_WEBSITE_URL": "https://bisq.markets",
|
||||
"MINING_DASHBOARD": true
|
||||
}
|
||||
|
@ -31,9 +31,12 @@
|
||||
<li class="nav-item" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}" id="btn-home">
|
||||
<a class="nav-link" [routerLink]="['/' | relativeUrl]" (click)="collapse()"><fa-icon [icon]="['fas', 'tachometer-alt']" [fixedWidth]="true" i18n-title="master-page.dashboard" title="Dashboard"></fa-icon></a>
|
||||
</li>
|
||||
<li class="nav-item" routerLinkActive="active" id="btn-pools">
|
||||
<li class="nav-item" routerLinkActive="active" id="btn-pools" *ngIf="stateService.env.MINING_DASHBOARD">
|
||||
<a class="nav-link" [routerLink]="['/mining/pools' | relativeUrl]" (click)="collapse()"><fa-icon [icon]="['fas', 'hammer']" [fixedWidth]="true" i18n-title="master-page.mining-pools" title="Mining Pools"></fa-icon></a>
|
||||
</li>
|
||||
<li class="nav-item" routerLinkActive="active" id="btn-blocks" *ngIf="!stateService.env.MINING_DASHBOARD">
|
||||
<a class="nav-link" [routerLink]="['/blocks' | relativeUrl]" (click)="collapse()"><fa-icon [icon]="['fas', 'cubes']" [fixedWidth]="true" i18n-title="master-page.blocks" title="Blocks"></fa-icon></a>
|
||||
</li>
|
||||
<li class="nav-item" routerLinkActive="active" id="btn-graphs">
|
||||
<a class="nav-link" [routerLink]="['/graphs' | relativeUrl]" (click)="collapse()"><fa-icon [icon]="['fas', 'chart-area']" [fixedWidth]="true" i18n-title="master-page.graphs" title="Graphs"></fa-icon></a>
|
||||
</li>
|
||||
|
@ -18,7 +18,7 @@ export class MasterPageComponent implements OnInit {
|
||||
urlLanguage: string;
|
||||
|
||||
constructor(
|
||||
private stateService: StateService,
|
||||
public stateService: StateService,
|
||||
private languageService: LanguageService,
|
||||
) { }
|
||||
|
||||
|
@ -36,6 +36,7 @@ export interface Env {
|
||||
MEMPOOL_WEBSITE_URL: string;
|
||||
LIQUID_WEBSITE_URL: string;
|
||||
BISQ_WEBSITE_URL: string;
|
||||
MINING_DASHBOARD: boolean;
|
||||
}
|
||||
|
||||
const defaultEnv: Env = {
|
||||
@ -59,6 +60,7 @@ const defaultEnv: Env = {
|
||||
'MEMPOOL_WEBSITE_URL': 'https://mempool.space',
|
||||
'LIQUID_WEBSITE_URL': 'https://liquid.network',
|
||||
'BISQ_WEBSITE_URL': 'https://bisq.markets',
|
||||
'MINING_DASHBOARD': true
|
||||
};
|
||||
|
||||
@Injectable({
|
||||
|
Loading…
Reference in New Issue
Block a user