mirror of
https://github.com/mempool/mempool.git
synced 2025-01-17 18:52:34 +01:00
Renamed the electrs backend support to 'electrs'.
This commit is contained in:
parent
aa8bccdb8f
commit
d1fce86adb
@ -20,6 +20,6 @@
|
||||
"BITCOIN_NODE_USER": "",
|
||||
"BITCOIN_NODE_PASS": "",
|
||||
"BACKEND_API": "bitcoind",
|
||||
"ESPLORA_API_URL": "https://www.blockstream.info/api",
|
||||
"ELECTRS_API_URL": "https://www.blockstream.info/api",
|
||||
"TX_PER_SECOND_SPAN_SECONDS": 150
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
const config = require('../../../mempool-config.json');
|
||||
import { AbstractBitcoinApi } from './bitcoin-api-abstract-factory';
|
||||
import BitcoindApi from './bitcoind-api';
|
||||
import EsploraApi from './esplora-api';
|
||||
import ElectrsApi from './electrs-api';
|
||||
|
||||
function factory(): AbstractBitcoinApi {
|
||||
switch (config.BACKEND_API) {
|
||||
case 'esplora':
|
||||
return new EsploraApi();
|
||||
case 'electrs':
|
||||
return new ElectrsApi();
|
||||
case 'bitcoind':
|
||||
default:
|
||||
return new BitcoindApi();
|
||||
|
@ -3,14 +3,14 @@ import { ITransaction, IMempoolInfo, IBlock } from '../../interfaces';
|
||||
import { AbstractBitcoinApi } from './bitcoin-api-abstract-factory';
|
||||
import * as request from 'request';
|
||||
|
||||
class EsploraApi implements AbstractBitcoinApi {
|
||||
class ElectrsApi implements AbstractBitcoinApi {
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
getMempoolInfo(): Promise<IMempoolInfo> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
request(config.ESPLORA_API_URL + '/mempool', { json: true }, (err, res, response) => {
|
||||
request(config.ELECTRS_API_URL + '/mempool', { json: true }, (err, res, response) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
@ -24,7 +24,7 @@ class EsploraApi implements AbstractBitcoinApi {
|
||||
|
||||
getRawMempool(): Promise<ITransaction['txid'][]> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
request(config.ESPLORA_API_URL + '/mempool/txids', { json: true }, (err, res, response) => {
|
||||
request(config.ELECTRS_API_URL + '/mempool/txids', { json: true }, (err, res, response) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
@ -35,7 +35,7 @@ class EsploraApi implements AbstractBitcoinApi {
|
||||
|
||||
getRawTransaction(txId: string): Promise<ITransaction> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
request(config.ESPLORA_API_URL + '/tx/' + txId, { json: true }, (err, res, response) => {
|
||||
request(config.ELECTRS_API_URL + '/tx/' + txId, { json: true }, (err, res, response) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
@ -50,7 +50,7 @@ class EsploraApi implements AbstractBitcoinApi {
|
||||
|
||||
getBlockCount(): Promise<number> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
request(config.ESPLORA_API_URL + '/blocks/tip/height', { json: true }, (err, res, response) => {
|
||||
request(config.ELECTRS_API_URL + '/blocks/tip/height', { json: true }, (err, res, response) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
@ -61,11 +61,11 @@ class EsploraApi implements AbstractBitcoinApi {
|
||||
|
||||
getBlockAndTransactions(hash: string): Promise<IBlock> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
request(config.ESPLORA_API_URL + '/block/' + hash, { json: true }, (err, res, response) => {
|
||||
request(config.ELECTRS_API_URL + '/block/' + hash, { json: true }, (err, res, response) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
request(config.ESPLORA_API_URL + '/block/' + hash + '/txids', { json: true }, (err2, res2, response2) => {
|
||||
request(config.ELECTRS_API_URL + '/block/' + hash + '/txids', { json: true }, (err2, res2, response2) => {
|
||||
if (err2) {
|
||||
reject(err2);
|
||||
}
|
||||
@ -83,7 +83,7 @@ class EsploraApi implements AbstractBitcoinApi {
|
||||
|
||||
getBlockHash(height: number): Promise<string> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
request(config.ESPLORA_API_URL + '/block-height/' + height, { json: true }, (err, res, response) => {
|
||||
request(config.ELECTRS_API_URL + '/block-height/' + height, { json: true }, (err, res, response) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
@ -94,7 +94,7 @@ class EsploraApi implements AbstractBitcoinApi {
|
||||
|
||||
getBlocks(): Promise<string> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
request(config.ESPLORA_API_URL + '/blocks', { json: true }, (err, res, response) => {
|
||||
request(config.ELECTRS_API_URL + '/blocks', { json: true }, (err, res, response) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
@ -105,7 +105,7 @@ class EsploraApi implements AbstractBitcoinApi {
|
||||
|
||||
getBlocksFromHeight(height: number): Promise<string> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
request(config.ESPLORA_API_URL + '/blocks/' + height, { json: true }, (err, res, response) => {
|
||||
request(config.ELECTRS_API_URL + '/blocks/' + height, { json: true }, (err, res, response) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
@ -116,7 +116,7 @@ class EsploraApi implements AbstractBitcoinApi {
|
||||
|
||||
getBlock(hash: string): Promise<IBlock> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
request(config.ESPLORA_API_URL + '/block/' + hash, { json: true }, (err, res, response) => {
|
||||
request(config.ELECTRS_API_URL + '/block/' + hash, { json: true }, (err, res, response) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
@ -127,7 +127,7 @@ class EsploraApi implements AbstractBitcoinApi {
|
||||
|
||||
getBlockTransactions(hash: string): Promise<IBlock> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
request(config.ESPLORA_API_URL + '/block/' + hash + '/txs', { json: true }, (err, res, response) => {
|
||||
request(config.ELECTRS_API_URL + '/block/' + hash + '/txs', { json: true }, (err, res, response) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
@ -138,7 +138,7 @@ class EsploraApi implements AbstractBitcoinApi {
|
||||
|
||||
getBlockTransactionsFromIndex(hash: string, index: number): Promise<IBlock> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
request(config.ESPLORA_API_URL + '/block/' + hash + '/txs/' + index, { json: true }, (err, res, response) => {
|
||||
request(config.ELECTRS_API_URL + '/block/' + hash + '/txs/' + index, { json: true }, (err, res, response) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
@ -149,7 +149,7 @@ class EsploraApi implements AbstractBitcoinApi {
|
||||
|
||||
getAddress(address: string): Promise<IBlock> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
request(config.ESPLORA_API_URL + '/address/' + address, { json: true }, (err, res, response) => {
|
||||
request(config.ELECTRS_API_URL + '/address/' + address, { json: true }, (err, res, response) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
@ -160,7 +160,7 @@ class EsploraApi implements AbstractBitcoinApi {
|
||||
|
||||
getAddressTransactions(address: string): Promise<IBlock> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
request(config.ESPLORA_API_URL + '/address/' + address + '/txs', { json: true }, (err, res, response) => {
|
||||
request(config.ELECTRS_API_URL + '/address/' + address + '/txs', { json: true }, (err, res, response) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
@ -171,7 +171,7 @@ class EsploraApi implements AbstractBitcoinApi {
|
||||
|
||||
getAddressTransactionsFromLastSeenTxid(address: string, lastSeenTxid: string): Promise<IBlock> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
request(config.ESPLORA_API_URL + '/address/' + address + '/txs/chain/' + lastSeenTxid, { json: true }, (err, res, response) => {
|
||||
request(config.ELECTRS_API_URL + '/address/' + address + '/txs/chain/' + lastSeenTxid, { json: true }, (err, res, response) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
@ -181,4 +181,4 @@ class EsploraApi implements AbstractBitcoinApi {
|
||||
}
|
||||
}
|
||||
|
||||
export default EsploraApi;
|
||||
export default ElectrsApi;
|
@ -56,7 +56,7 @@ class Mempool {
|
||||
let totalOut = 0;
|
||||
transaction.vout.forEach((output) => totalOut += output.value);
|
||||
|
||||
if (config.BACKEND_API === 'esplora') {
|
||||
if (config.BACKEND_API === 'electrs') {
|
||||
transaction.feePerWeightUnit = (transaction.fee * 100000000) / transaction.weight || 0;
|
||||
transaction.feePerVsize = (transaction.fee * 100000000) / (transaction.vsize) || 0;
|
||||
transaction.totalOut = totalOut / 100000000;
|
||||
|
@ -264,7 +264,7 @@ class MempoolSpace {
|
||||
.get(config.API_ENDPOINT + 'statistics/6m', routes.get6MStatistics.bind(routes))
|
||||
;
|
||||
|
||||
if (config.BACKEND_API === 'esplora') {
|
||||
if (config.BACKEND_API === 'electrs') {
|
||||
this.app
|
||||
.get(config.API_ENDPOINT + 'explorer/blocks', routes.getBlocks)
|
||||
.get(config.API_ENDPOINT + 'explorer/blocks/:height', routes.getBlocks)
|
||||
|
@ -49,11 +49,11 @@
|
||||
"vendorChunk": false,
|
||||
"buildOptimizer": true
|
||||
},
|
||||
"esplora": {
|
||||
"electrs": {
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "src/environments/environment.ts",
|
||||
"with": "src/environments/environment-esplora.prod.ts"
|
||||
"with": "src/environments/environment-electrs.prod.ts"
|
||||
}
|
||||
],
|
||||
"optimization": true,
|
||||
|
@ -6,7 +6,7 @@
|
||||
"ng": "ng",
|
||||
"start": "ng serve --aot --proxy-config proxy.conf.json",
|
||||
"build": "ng build --prod",
|
||||
"build-esplora": "ng build --prod --configuration=esplora",
|
||||
"build-electrs": "ng build --prod --configuration=electrs",
|
||||
"test": "ng test",
|
||||
"lint": "ng lint",
|
||||
"e2e": "ng e2e"
|
||||
|
@ -1,7 +1,7 @@
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Fee distribution for block
|
||||
<a *ngIf="!isEsploraEnabled" href="https://www.blockstream.info/block-height/{{ block.height }}" target="_blank">#{{ block.height }}</a>
|
||||
<a *ngIf="isEsploraEnabled" (click)="activeModal.dismiss()" [routerLink]="['/explorer/block/', block.hash]">#{{ block.height }}</a>
|
||||
<a *ngIf="!isElectrsEnabled" href="https://www.blockstream.info/block-height/{{ block.height }}" target="_blank">#{{ block.height }}</a>
|
||||
<a *ngIf="isElectrsEnabled" (click)="activeModal.dismiss()" [routerLink]="['/explorer/block/', block.hash]">#{{ block.height }}</a>
|
||||
</h4>
|
||||
<button type="button" class="close" aria-label="Close" (click)="activeModal.dismiss('Cross click')">
|
||||
<span aria-hidden="true">×</span>
|
||||
|
@ -12,7 +12,7 @@ import { environment } from '../../../environments/environment';
|
||||
export class BlockModalComponent implements OnInit {
|
||||
@Input() block: IBlock;
|
||||
blockSubsidy = 50;
|
||||
isEsploraEnabled = !!environment.esplora;
|
||||
isElectrsEnabled = !!environment.electrs;
|
||||
conversions: any;
|
||||
|
||||
constructor(
|
||||
|
@ -2,8 +2,8 @@
|
||||
<div *ngFor="let block of blocks; let i = index; trackBy: trackByBlocksFn" >
|
||||
<div (click)="openBlockModal(block);" class="text-center bitcoin-block mined-block" id="bitcoin-block-{{ block.height }}" [ngStyle]="getStyleForBlock(block)">
|
||||
<div class="block-height">
|
||||
<a *ngIf="!isEsploraEnabled" href="https://www.blockstream.info/block-height/{{ block.height }}" target="_blank">#{{ block.height }}</a>
|
||||
<a *ngIf="isEsploraEnabled" [routerLink]="['/explorer/block/', block.hash]">#{{ block.height }}</a>
|
||||
<a *ngIf="!isElectrsEnabled" href="https://www.blockstream.info/block-height/{{ block.height }}" target="_blank">#{{ block.height }}</a>
|
||||
<a *ngIf="isElectrsEnabled" [routerLink]="['/explorer/block/', block.hash]">#{{ block.height }}</a>
|
||||
</div>
|
||||
<div class="block-body">
|
||||
<div class="fees">
|
||||
|
@ -16,7 +16,7 @@ export class BlockchainBlocksComponent implements OnInit, OnDestroy {
|
||||
blocksSubscription: Subscription;
|
||||
interval: any;
|
||||
trigger = 0;
|
||||
isEsploraEnabled = !!environment.esplora;
|
||||
isElectrsEnabled = !!environment.electrs;
|
||||
|
||||
constructor(
|
||||
private modalService: NgbModal,
|
||||
|
@ -18,7 +18,7 @@
|
||||
<li class="nav-item" routerLinkActive="active">
|
||||
<a class="nav-link" routerLink="/tv" (click)="collapse()">TV view <img src="./assets/expand.png" width="15"/></a>
|
||||
</li>
|
||||
<li class="nav-item" routerLinkActive="active" *ngIf="isEsploraEnabled">
|
||||
<li class="nav-item" routerLinkActive="active" *ngIf="isElectrsEnabled">
|
||||
<a class="nav-link" routerLink="/explorer" (click)="collapse()">Explorer</a>
|
||||
</li>
|
||||
<li class="nav-item" routerLinkActive="active">
|
||||
|
@ -13,7 +13,7 @@ export class MasterPageComponent implements OnInit {
|
||||
navCollapsed = false;
|
||||
isOffline = false;
|
||||
searchForm: FormGroup;
|
||||
isEsploraEnabled = !!environment.esplora;
|
||||
isElectrsEnabled = !!environment.electrs;
|
||||
currentBaseRoot = '';
|
||||
|
||||
regexAddr = /^([a-km-zA-HJ-NP-Z1-9]{26,35}|[a-km-zA-HJ-NP-Z1-9]{80}|[a-z]{2,5}1[ac-hj-np-z02-9]{8,87})$/;
|
||||
|
@ -4,8 +4,8 @@
|
||||
<tr>
|
||||
<td class="text-left"><b>Transaction hash</b></td>
|
||||
<td class="text-right">
|
||||
<a *ngIf="!isEsploraEnabled" href="https://www.blockstream.info/tx/{{ tx?.txid }}" target="_blank">{{ tx?.txid | shortenString }}</a>
|
||||
<a *ngIf="isEsploraEnabled" [routerLink]="['/explorer/tx/', tx?.txid]">{{ tx?.txid | shortenString }}</a>
|
||||
<a *ngIf="!isElectrsEnabled" href="https://www.blockstream.info/tx/{{ tx?.txid }}" target="_blank">{{ tx?.txid | shortenString }}</a>
|
||||
<a *ngIf="isElectrsEnabled" [routerLink]="['/explorer/tx/', tx?.txid]">{{ tx?.txid | shortenString }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -36,7 +36,7 @@ export class TxBubbleComponent implements OnInit, OnDestroy {
|
||||
txTrackingTx: ITransaction | null = null;
|
||||
txShowTxNotFound = false;
|
||||
|
||||
isEsploraEnabled = !!environment.esplora;
|
||||
isElectrsEnabled = !!environment.electrs;
|
||||
|
||||
@HostListener('window:resize', ['$event'])
|
||||
onResize(event: Event) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
export const environment = {
|
||||
production: true,
|
||||
esplora: true,
|
||||
electrs: true,
|
||||
};
|
@ -1,4 +1,4 @@
|
||||
export const environment = {
|
||||
production: true,
|
||||
esplora: false,
|
||||
electrs: false,
|
||||
};
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
export const environment = {
|
||||
production: false,
|
||||
esplora: true,
|
||||
electrs: true,
|
||||
};
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user