Merge pull request #1375 from nymkappa/feature/index-coinbase-scriptsig
Index asciiScriptSig and display it in /mining/blocks
This commit is contained in:
commit
4ecacde10b
@ -108,9 +108,7 @@ class Blocks {
|
|||||||
const blockExtended: BlockExtended = Object.assign({ extras: {} }, block);
|
const blockExtended: BlockExtended = Object.assign({ extras: {} }, block);
|
||||||
blockExtended.extras.reward = transactions[0].vout.reduce((acc, curr) => acc + curr.value, 0);
|
blockExtended.extras.reward = transactions[0].vout.reduce((acc, curr) => acc + curr.value, 0);
|
||||||
blockExtended.extras.coinbaseTx = transactionUtils.stripCoinbaseTransaction(transactions[0]);
|
blockExtended.extras.coinbaseTx = transactionUtils.stripCoinbaseTransaction(transactions[0]);
|
||||||
|
blockExtended.extras.coinbaseRaw = blockExtended.extras.coinbaseTx.vin[0].scriptsig;
|
||||||
const coinbaseRaw: IEsploraApi.Transaction = await bitcoinApi.$getRawTransaction(transactions[0].txid, true, false, block.id);
|
|
||||||
blockExtended.extras.coinbaseRaw = coinbaseRaw.hex;
|
|
||||||
|
|
||||||
if (block.height === 0) {
|
if (block.height === 0) {
|
||||||
blockExtended.extras.medianFee = 0; // 50th percentiles
|
blockExtended.extras.medianFee = 0; // 50th percentiles
|
||||||
@ -410,6 +408,7 @@ class Blocks {
|
|||||||
weight: block.weight,
|
weight: block.weight,
|
||||||
previousblockhash: block.previousblockhash,
|
previousblockhash: block.previousblockhash,
|
||||||
extras: {
|
extras: {
|
||||||
|
coinbaseRaw: block.coinbase_raw ?? block.extras.coinbaseRaw,
|
||||||
medianFee: block.medianFee ?? block.median_fee ?? block.extras?.medianFee,
|
medianFee: block.medianFee ?? block.median_fee ?? block.extras?.medianFee,
|
||||||
feeRange: block.feeRange ?? block.fee_range ?? block?.extras?.feeSpan,
|
feeRange: block.feeRange ?? block.fee_range ?? block?.extras?.feeSpan,
|
||||||
reward: block.reward ?? block?.extras?.reward,
|
reward: block.reward ?? block?.extras?.reward,
|
||||||
|
@ -6,7 +6,7 @@ import logger from '../logger';
|
|||||||
const sleep = (ms: number) => new Promise(res => setTimeout(res, ms));
|
const sleep = (ms: number) => new Promise(res => setTimeout(res, ms));
|
||||||
|
|
||||||
class DatabaseMigration {
|
class DatabaseMigration {
|
||||||
private static currentVersion = 14;
|
private static currentVersion = 15;
|
||||||
private queryTimeout = 120000;
|
private queryTimeout = 120000;
|
||||||
private statisticsAddedIndexed = false;
|
private statisticsAddedIndexed = false;
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ class BlocksRepository {
|
|||||||
logger.debug(`$saveBlockInDatabase() - Block ${block.height} has already been indexed, ignoring`);
|
logger.debug(`$saveBlockInDatabase() - Block ${block.height} has already been indexed, ignoring`);
|
||||||
} else {
|
} else {
|
||||||
connection.release();
|
connection.release();
|
||||||
logger.err('$saveBlockInDatabase() error' + (e instanceof Error ? e.message : e));
|
logger.err('$saveBlockInDatabase() error: ' + (e instanceof Error ? e.message : e));
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,11 +24,14 @@
|
|||||||
}}</a>
|
}}</a>
|
||||||
</td>
|
</td>
|
||||||
<td class="pool text-left" [class]="widget ? 'widget' : ''">
|
<td class="pool text-left" [class]="widget ? 'widget' : ''">
|
||||||
<a class="clear-link" [routerLink]="[('/mining/pool/' + block.extras.pool.id) | relativeUrl]">
|
<div class="tooltip-custom">
|
||||||
<img width="25" height="25" src="{{ block.extras.pool['logo'] }}"
|
<a class="clear-link" [routerLink]="[('/mining/pool/' + block.extras.pool.id) | relativeUrl]">
|
||||||
onError="this.src = './resources/mining-pools/default.svg'">
|
<img width="25" height="25" src="{{ block.extras.pool['logo'] }}"
|
||||||
<span class="pool-name">{{ block.extras.pool.name }}</span>
|
onError="this.src = './resources/mining-pools/default.svg'">
|
||||||
</a>
|
<span class="pool-name">{{ block.extras.pool.name }}</span>
|
||||||
|
</a>
|
||||||
|
<span class="tooltiptext">{{ block.extras.coinbaseRaw | hex2ascii }}</span>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="timestamp" *ngIf="!widget">
|
<td class="timestamp" *ngIf="!widget">
|
||||||
‎{{ block.timestamp * 1000 | date:'yyyy-MM-dd HH:mm' }}
|
‎{{ block.timestamp * 1000 | date:'yyyy-MM-dd HH:mm' }}
|
||||||
|
@ -122,3 +122,27 @@ td {
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Tooltip text */
|
||||||
|
.tooltip-custom {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tooltip-custom .tooltiptext {
|
||||||
|
visibility: hidden;
|
||||||
|
background-color: black;
|
||||||
|
color: #fff;
|
||||||
|
text-align: center;
|
||||||
|
padding: 5px 0;
|
||||||
|
border-radius: 6px;
|
||||||
|
position: absolute;
|
||||||
|
z-index: 1;
|
||||||
|
// width: 120px;
|
||||||
|
top: -40px;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Show the tooltip text when you mouse over the tooltip container */
|
||||||
|
.tooltip-custom:hover .tooltiptext {
|
||||||
|
visibility: visible;
|
||||||
|
}
|
@ -102,6 +102,7 @@ export interface BlockExtension {
|
|||||||
feeRange?: number[];
|
feeRange?: number[];
|
||||||
reward?: number;
|
reward?: number;
|
||||||
coinbaseTx?: Transaction;
|
coinbaseTx?: Transaction;
|
||||||
|
coinbaseRaw?: string;
|
||||||
matchRate?: number;
|
matchRate?: number;
|
||||||
pool?: {
|
pool?: {
|
||||||
id: number;
|
id: number;
|
||||||
|
@ -15,11 +15,11 @@ export class Hex2asciiPipe implements PipeTransform {
|
|||||||
if (!hex) {
|
if (!hex) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
let bytes: number[] = [];
|
const bytes: number[] = [];
|
||||||
for (let i = 0; i < hex.length; i += 2) {
|
for (let i = 0; i < hex.length; i += 2) {
|
||||||
bytes.push(parseInt(hex.substr(i, 2), 16));
|
bytes.push(parseInt(hex.substr(i, 2), 16));
|
||||||
}
|
}
|
||||||
return new TextDecoder('utf8').decode(Uint8Array.from(bytes));
|
return new TextDecoder('utf8').decode(Uint8Array.from(bytes)).replace(/\uFFFD/g, '').replace(/\\0/g, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user