mirror of
https://github.com/mempool/mempool.git
synced 2024-12-27 08:44:26 +01:00
Merge pull request #1739 from mempool/nymkappa/bugfix/block-url-link
Use block hash instead of block height in urls
This commit is contained in:
commit
9a9be2538a
@ -253,8 +253,26 @@ class BlocksRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const params: any[] = [];
|
const params: any[] = [];
|
||||||
let query = ` SELECT *, UNIX_TIMESTAMP(blocks.blockTimestamp) as blockTimestamp,
|
let query = ` SELECT
|
||||||
previous_block_hash as previousblockhash
|
height,
|
||||||
|
hash as id,
|
||||||
|
UNIX_TIMESTAMP(blocks.blockTimestamp) as blockTimestamp,
|
||||||
|
size,
|
||||||
|
weight,
|
||||||
|
tx_count,
|
||||||
|
coinbase_raw,
|
||||||
|
difficulty,
|
||||||
|
fees,
|
||||||
|
fee_span,
|
||||||
|
median_fee,
|
||||||
|
reward,
|
||||||
|
version,
|
||||||
|
bits,
|
||||||
|
nonce,
|
||||||
|
merkle_root,
|
||||||
|
previous_block_hash as previousblockhash,
|
||||||
|
avg_fee,
|
||||||
|
avg_fee_rate
|
||||||
FROM blocks
|
FROM blocks
|
||||||
WHERE pool_id = ?`;
|
WHERE pool_id = ?`;
|
||||||
params.push(pool.id);
|
params.push(pool.id);
|
||||||
@ -287,11 +305,32 @@ class BlocksRepository {
|
|||||||
*/
|
*/
|
||||||
public async $getBlockByHeight(height: number): Promise<object | null> {
|
public async $getBlockByHeight(height: number): Promise<object | null> {
|
||||||
try {
|
try {
|
||||||
const [rows]: any[] = await DB.query(`
|
const [rows]: any[] = await DB.query(`SELECT
|
||||||
SELECT *, UNIX_TIMESTAMP(blocks.blockTimestamp) as blockTimestamp,
|
height,
|
||||||
pools.id as pool_id, pools.name as pool_name, pools.link as pool_link, pools.slug as pool_slug,
|
hash as id,
|
||||||
pools.addresses as pool_addresses, pools.regexes as pool_regexes,
|
UNIX_TIMESTAMP(blocks.blockTimestamp) as blockTimestamp,
|
||||||
previous_block_hash as previousblockhash
|
size,
|
||||||
|
weight,
|
||||||
|
tx_count,
|
||||||
|
coinbase_raw,
|
||||||
|
difficulty,
|
||||||
|
pools.id as pool_id,
|
||||||
|
pools.name as pool_name,
|
||||||
|
pools.link as pool_link,
|
||||||
|
pools.slug as pool_slug,
|
||||||
|
pools.addresses as pool_addresses,
|
||||||
|
pools.regexes as pool_regexes,
|
||||||
|
fees,
|
||||||
|
fee_span,
|
||||||
|
median_fee,
|
||||||
|
reward,
|
||||||
|
version,
|
||||||
|
bits,
|
||||||
|
nonce,
|
||||||
|
merkle_root,
|
||||||
|
previous_block_hash as previousblockhash,
|
||||||
|
avg_fee,
|
||||||
|
avg_fee_rate
|
||||||
FROM blocks
|
FROM blocks
|
||||||
JOIN pools ON blocks.pool_id = pools.id
|
JOIN pools ON blocks.pool_id = pools.id
|
||||||
WHERE height = ${height};
|
WHERE height = ${height};
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
<tbody *ngIf="blocks$ | async as blocks; else skeleton" [style]="isLoading ? 'opacity: 0.75' : ''">
|
<tbody *ngIf="blocks$ | async as blocks; else skeleton" [style]="isLoading ? 'opacity: 0.75' : ''">
|
||||||
<tr *ngFor="let block of blocks; let i= index; trackBy: trackByBlock">
|
<tr *ngFor="let block of blocks; let i= index; trackBy: trackByBlock">
|
||||||
<td class="text-left" [class]="widget ? 'widget' : ''">
|
<td class="text-left" [class]="widget ? 'widget' : ''">
|
||||||
<a [routerLink]="['/block' | relativeUrl, block.height]">{{ block.height }}</a>
|
<a [routerLink]="['/block' | relativeUrl, block.id]" [state]="{ data: { block: block } }">{{ block.height }}</a>
|
||||||
</td>
|
</td>
|
||||||
<td *ngIf="indexingAvailable" class="pool text-left" [ngClass]="{'widget': widget, 'legacy': !indexingAvailable}">
|
<td *ngIf="indexingAvailable" class="pool text-left" [ngClass]="{'widget': widget, 'legacy': !indexingAvailable}">
|
||||||
<div class="tooltip-custom">
|
<div class="tooltip-custom">
|
||||||
|
@ -221,8 +221,7 @@
|
|||||||
<tbody [style]="isLoading ? 'opacity: 0.75' : ''">
|
<tbody [style]="isLoading ? 'opacity: 0.75' : ''">
|
||||||
<tr *ngFor="let block of blocks; let i= index; trackBy: trackByBlock">
|
<tr *ngFor="let block of blocks; let i= index; trackBy: trackByBlock">
|
||||||
<td class="height">
|
<td class="height">
|
||||||
<a [routerLink]="['/block' | relativeUrl, block.height]">{{ block.height
|
<a [routerLink]="['/block' | relativeUrl, block.id]">{{ block.height }}</a>
|
||||||
}}</a>
|
|
||||||
</td>
|
</td>
|
||||||
<td class="timestamp">
|
<td class="timestamp">
|
||||||
‎{{ block.timestamp * 1000 | date:'yyyy-MM-dd HH:mm' }}
|
‎{{ block.timestamp * 1000 | date:'yyyy-MM-dd HH:mm' }}
|
||||||
|
Loading…
Reference in New Issue
Block a user