Make Block Weight Unit configurable in frontend+backend.
This commit is contained in:
parent
a32c1f40b1
commit
037f472f8c
@ -8,7 +8,8 @@
|
|||||||
"POLL_RATE_MS": 2000,
|
"POLL_RATE_MS": 2000,
|
||||||
"CACHE_DIR": "./cache",
|
"CACHE_DIR": "./cache",
|
||||||
"CLEAR_PROTECTION_MINUTES": 20,
|
"CLEAR_PROTECTION_MINUTES": 20,
|
||||||
"RECOMMENDED_FEE_PERCENTILE": 50
|
"RECOMMENDED_FEE_PERCENTILE": 50,
|
||||||
|
"BLOCK_WEIGHT_UNITS": 4000000
|
||||||
},
|
},
|
||||||
"CORE_RPC": {
|
"CORE_RPC": {
|
||||||
"HOST": "127.0.0.1",
|
"HOST": "127.0.0.1",
|
||||||
|
@ -76,7 +76,7 @@ class MempoolBlocks {
|
|||||||
let blockSize = 0;
|
let blockSize = 0;
|
||||||
let transactions: TransactionExtended[] = [];
|
let transactions: TransactionExtended[] = [];
|
||||||
transactionsSorted.forEach((tx) => {
|
transactionsSorted.forEach((tx) => {
|
||||||
if (blockVSize + tx.vsize <= 1000000 || mempoolBlocks.length === MempoolBlocks.DEFAULT_PROJECTED_BLOCKS_AMOUNT - 1) {
|
if (blockVSize + tx.weight <= config.MEMPOOL.BLOCK_WEIGHT_UNITS || mempoolBlocks.length === MempoolBlocks.DEFAULT_PROJECTED_BLOCKS_AMOUNT - 1) {
|
||||||
blockVSize += tx.vsize;
|
blockVSize += tx.vsize;
|
||||||
blockSize += tx.size;
|
blockSize += tx.size;
|
||||||
transactions.push(tx);
|
transactions.push(tx);
|
||||||
|
@ -11,6 +11,7 @@ interface IConfig {
|
|||||||
CACHE_DIR: string;
|
CACHE_DIR: string;
|
||||||
CLEAR_PROTECTION_MINUTES: number;
|
CLEAR_PROTECTION_MINUTES: number;
|
||||||
RECOMMENDED_FEE_PERCENTILE: number;
|
RECOMMENDED_FEE_PERCENTILE: number;
|
||||||
|
BLOCK_WEIGHT_UNITS: number;
|
||||||
};
|
};
|
||||||
ESPLORA: {
|
ESPLORA: {
|
||||||
REST_API_URL: string;
|
REST_API_URL: string;
|
||||||
@ -69,6 +70,7 @@ const defaults: IConfig = {
|
|||||||
'CACHE_DIR': './cache',
|
'CACHE_DIR': './cache',
|
||||||
'CLEAR_PROTECTION_MINUTES': 20,
|
'CLEAR_PROTECTION_MINUTES': 20,
|
||||||
'RECOMMENDED_FEE_PERCENTILE': 50,
|
'RECOMMENDED_FEE_PERCENTILE': 50,
|
||||||
|
'BLOCK_WEIGHT_UNITS': 4000000,
|
||||||
},
|
},
|
||||||
'ESPLORA': {
|
'ESPLORA': {
|
||||||
'REST_API_URL': 'http://127.0.0.1:3000',
|
'REST_API_URL': 'http://127.0.0.1:3000',
|
||||||
|
@ -9,5 +9,6 @@
|
|||||||
"NGINX_PROTOCOL": "http",
|
"NGINX_PROTOCOL": "http",
|
||||||
"NGINX_HOSTNAME": "127.0.0.1",
|
"NGINX_HOSTNAME": "127.0.0.1",
|
||||||
"NGINX_PORT": "80",
|
"NGINX_PORT": "80",
|
||||||
|
"BLOCK_WEIGHT_UNITS": 4000000,
|
||||||
"BASE_MODULE": "mempool"
|
"BASE_MODULE": "mempool"
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ export class FooterComponent implements OnInit {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
size: size,
|
size: size,
|
||||||
blocks: Math.ceil(vsize / 1000000)
|
blocks: Math.ceil(vsize / this.stateService.blockVSize)
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
<td i18n="mempool-block.size">Size</td>
|
<td i18n="mempool-block.size">Size</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="progress">
|
<div class="progress">
|
||||||
<div class="progress-bar progress-mempool {{ (network$ | async) }}" role="progressbar" [ngStyle]="{'width': (mempoolBlock.blockVSize / 1000000) * 100 + '%' }"></div>
|
<div class="progress-bar progress-mempool {{ (network$ | async) }}" role="progressbar" [ngStyle]="{'width': (mempoolBlock.blockVSize / stateService.blockVSize) * 100 + '%' }"></div>
|
||||||
<div class="progress-text" [innerHTML]="mempoolBlock.blockSize | bytes: 2"></div>
|
<div class="progress-text" [innerHTML]="mempoolBlock.blockSize | bytes: 2"></div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
@ -21,7 +21,7 @@ export class MempoolBlockComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private stateService: StateService,
|
public stateService: StateService,
|
||||||
private seoService: SeoService,
|
private seoService: SeoService,
|
||||||
private websocketService: WebsocketService,
|
private websocketService: WebsocketService,
|
||||||
) { }
|
) { }
|
||||||
@ -66,7 +66,7 @@ export class MempoolBlockComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getOrdinal(mempoolBlock: MempoolBlock): string {
|
getOrdinal(mempoolBlock: MempoolBlock): string {
|
||||||
const blocksInBlock = Math.ceil(mempoolBlock.blockVSize / 1000000);
|
const blocksInBlock = Math.ceil(mempoolBlock.blockVSize / this.stateService.blockVSize);
|
||||||
if (this.mempoolBlockIndex === 0) {
|
if (this.mempoolBlockIndex === 0) {
|
||||||
return $localize`:@@mempool-block.next.block:Next block`;
|
return $localize`:@@mempool-block.next.block:Next block`;
|
||||||
} else if (this.mempoolBlockIndex === this.stateService.env.KEEP_BLOCKS_AMOUNT - 1 && blocksInBlock > 1) {
|
} else if (this.mempoolBlockIndex === this.stateService.env.KEEP_BLOCKS_AMOUNT - 1 && blocksInBlock > 1) {
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<ng-template #transactionsSingular let-i i18n="shared.transaction-count.singular">{{ i }} transaction</ng-template>
|
<ng-template #transactionsSingular let-i i18n="shared.transaction-count.singular">{{ i }} transaction</ng-template>
|
||||||
<ng-template #transactionsPlural let-i i18n="shared.transaction-count.plural">{{ i }} transactions</ng-template>
|
<ng-template #transactionsPlural let-i i18n="shared.transaction-count.plural">{{ i }} transactions</ng-template>
|
||||||
</div>
|
</div>
|
||||||
<div class="time-difference" *ngIf="projectedBlock.blockVSize <= 1000000; else mergedBlock">
|
<div class="time-difference" *ngIf="projectedBlock.blockVSize <= stateService.blockVSize; else mergedBlock">
|
||||||
<ng-template [ngIf]="network === 'liquid'" [ngIfElse]="timeDiffMainnet">
|
<ng-template [ngIf]="network === 'liquid'" [ngIfElse]="timeDiffMainnet">
|
||||||
<app-time-until [time]="(1 * i) + now + 61000" [fastRender]="false" [fixedRender]="true"></app-time-until>
|
<app-time-until [time]="(1 * i) + now + 61000" [fastRender]="false" [fixedRender]="true"></app-time-until>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
@ -26,7 +26,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<ng-template #mergedBlock>
|
<ng-template #mergedBlock>
|
||||||
<div class="time-difference">
|
<div class="time-difference">
|
||||||
<b>(<ng-container *ngTemplateOutlet="blocksPlural; context: {$implicit: projectedBlock.blockVSize / 1000000 | ceil }"></ng-container>)</b>
|
<b>(<ng-container *ngTemplateOutlet="blocksPlural; context: {$implicit: projectedBlock.blockVSize / stateService.blockVSize | ceil }"></ng-container>)</b>
|
||||||
<ng-template #blocksPlural let-i i18n="shared.blocks">{{ i }} <span class="shared-block">blocks</span></ng-template>
|
<ng-template #blocksPlural let-i i18n="shared.blocks">{{ i }} <span class="shared-block">blocks</span></ng-template>
|
||||||
</div>
|
</div>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
@ -44,7 +44,7 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private stateService: StateService,
|
public stateService: StateService,
|
||||||
private cd: ChangeDetectorRef,
|
private cd: ChangeDetectorRef,
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
@ -202,7 +202,7 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getStyleForMempoolBlock(mempoolBlock: MempoolBlock, index: number) {
|
getStyleForMempoolBlock(mempoolBlock: MempoolBlock, index: number) {
|
||||||
const emptyBackgroundSpacePercentage = Math.max(100 - mempoolBlock.blockVSize / 1000000 * 100, 0);
|
const emptyBackgroundSpacePercentage = Math.max(100 - mempoolBlock.blockVSize / this.stateService.blockVSize * 100, 0);
|
||||||
const usedBlockSpace = 100 - emptyBackgroundSpacePercentage;
|
const usedBlockSpace = 100 - emptyBackgroundSpacePercentage;
|
||||||
const backgroundGradients = [`repeating-linear-gradient(to right, #554b45, #554b45 ${emptyBackgroundSpacePercentage}%`];
|
const backgroundGradients = [`repeating-linear-gradient(to right, #554b45, #554b45 ${emptyBackgroundSpacePercentage}%`];
|
||||||
const gradientColors = [];
|
const gradientColors = [];
|
||||||
@ -262,7 +262,7 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy {
|
|||||||
const chunkPositionOffset = blockLocation * feeRangeChunkSize;
|
const chunkPositionOffset = blockLocation * feeRangeChunkSize;
|
||||||
const feePosition = feeRangeChunkSize * feeRangeIndex + chunkPositionOffset;
|
const feePosition = feeRangeChunkSize * feeRangeIndex + chunkPositionOffset;
|
||||||
|
|
||||||
const blockedFilledPercentage = (block.blockVSize > 1000000 ? 1000000 : block.blockVSize) / 1000000;
|
const blockedFilledPercentage = (block.blockVSize > this.stateService.blockVSize ? this.stateService.blockVSize : block.blockVSize) / this.stateService.blockVSize;
|
||||||
const arrowRightPosition = txInBlockIndex * (this.blockWidth + this.blockPadding)
|
const arrowRightPosition = txInBlockIndex * (this.blockWidth + this.blockPadding)
|
||||||
+ ((1 - feePosition) * blockedFilledPercentage * this.blockWidth);
|
+ ((1 - feePosition) * blockedFilledPercentage * this.blockWidth);
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ export class MempoolGraphComponent implements OnInit, OnChanges {
|
|||||||
labelInterpolationFnc: (value: number): any => this.vbytesPipe.transform(value, 2, 'vB', 'MvB', true),
|
labelInterpolationFnc: (value: number): any => this.vbytesPipe.transform(value, 2, 'vB', 'MvB', true),
|
||||||
offset: this.showLegend ? 160 : 60,
|
offset: this.showLegend ? 160 : 60,
|
||||||
},
|
},
|
||||||
plugins: this.inverted ? [Chartist.plugins.ctTargetLine({ value: 1000000 })] : []
|
plugins: this.inverted ? [Chartist.plugins.ctTargetLine({ value: this.stateService.blockVSize })] : []
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.showLegend) {
|
if (this.showLegend) {
|
||||||
|
@ -207,7 +207,7 @@ export class DashboardComponent implements OnInit {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
size: size,
|
size: size,
|
||||||
blocks: Math.ceil(vsize / 1000000)
|
blocks: Math.ceil(vsize / this.stateService.blockVSize)
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -28,6 +28,7 @@ export interface Env {
|
|||||||
NGINX_PROTOCOL?: string;
|
NGINX_PROTOCOL?: string;
|
||||||
NGINX_HOSTNAME?: string;
|
NGINX_HOSTNAME?: string;
|
||||||
NGINX_PORT?: string;
|
NGINX_PORT?: string;
|
||||||
|
BLOCK_WEIGHT_UNITS: number;
|
||||||
GIT_COMMIT_HASH: string;
|
GIT_COMMIT_HASH: string;
|
||||||
PACKAGE_JSON_VERSION: string;
|
PACKAGE_JSON_VERSION: string;
|
||||||
}
|
}
|
||||||
@ -45,6 +46,7 @@ const defaultEnv: Env = {
|
|||||||
'NGINX_PROTOCOL': 'http',
|
'NGINX_PROTOCOL': 'http',
|
||||||
'NGINX_HOSTNAME': '127.0.0.1',
|
'NGINX_HOSTNAME': '127.0.0.1',
|
||||||
'NGINX_PORT': '80',
|
'NGINX_PORT': '80',
|
||||||
|
'BLOCK_WEIGHT_UNITS': 4000000,
|
||||||
'GIT_COMMIT_HASH': '',
|
'GIT_COMMIT_HASH': '',
|
||||||
'PACKAGE_JSON_VERSION': '',
|
'PACKAGE_JSON_VERSION': '',
|
||||||
};
|
};
|
||||||
@ -55,6 +57,7 @@ const defaultEnv: Env = {
|
|||||||
export class StateService {
|
export class StateService {
|
||||||
isBrowser: boolean = isPlatformBrowser(this.platformId);
|
isBrowser: boolean = isPlatformBrowser(this.platformId);
|
||||||
network = '';
|
network = '';
|
||||||
|
blockVSize: number;
|
||||||
env: Env;
|
env: Env;
|
||||||
latestBlockHeight = 0;
|
latestBlockHeight = 0;
|
||||||
|
|
||||||
@ -113,6 +116,8 @@ export class StateService {
|
|||||||
this.network = this.env.BASE_MODULE;
|
this.network = this.env.BASE_MODULE;
|
||||||
this.networkChanged$.next(this.env.BASE_MODULE);
|
this.networkChanged$.next(this.env.BASE_MODULE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.blockVSize = this.env.BLOCK_WEIGHT_UNITS / 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
setNetworkBasedonUrl(url: string) {
|
setNetworkBasedonUrl(url: string) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user