mirror of
https://github.com/mempool/mempool.git
synced 2025-02-22 06:21:46 +01:00
Merge branch 'master' into nymkappa/feature/update-ln-dashboard
This commit is contained in:
commit
8edbd60bbf
4 changed files with 53 additions and 17 deletions
|
@ -4,6 +4,8 @@ import { XMLParser } from 'fast-xml-parser';
|
||||||
import logger from '../../../logger';
|
import logger from '../../../logger';
|
||||||
import fundingTxFetcher from './funding-tx-fetcher';
|
import fundingTxFetcher from './funding-tx-fetcher';
|
||||||
import config from '../../../config';
|
import config from '../../../config';
|
||||||
|
import { ILightningApi } from '../../../api/lightning/lightning-api.interface';
|
||||||
|
import { isIP } from 'net';
|
||||||
|
|
||||||
const fsPromises = promises;
|
const fsPromises = promises;
|
||||||
|
|
||||||
|
@ -48,7 +50,7 @@ class LightningStatsImporter {
|
||||||
/**
|
/**
|
||||||
* Generate LN network stats for one day
|
* Generate LN network stats for one day
|
||||||
*/
|
*/
|
||||||
public async computeNetworkStats(timestamp: number, networkGraph): Promise<unknown> {
|
public async computeNetworkStats(timestamp: number, networkGraph: ILightningApi.NetworkGraph): Promise<unknown> {
|
||||||
// Node counts and network shares
|
// Node counts and network shares
|
||||||
let clearnetNodes = 0;
|
let clearnetNodes = 0;
|
||||||
let torNodes = 0;
|
let torNodes = 0;
|
||||||
|
@ -61,8 +63,8 @@ class LightningStatsImporter {
|
||||||
let isUnnanounced = true;
|
let isUnnanounced = true;
|
||||||
|
|
||||||
for (const socket of (node.addresses ?? [])) {
|
for (const socket of (node.addresses ?? [])) {
|
||||||
hasOnion = hasOnion || ['torv2', 'torv3'].includes(socket.network);
|
hasOnion = hasOnion || ['torv2', 'torv3'].includes(socket.network) || socket.addr.indexOf('onion') !== -1;
|
||||||
hasClearnet = hasClearnet || ['ipv4', 'ipv6'].includes(socket.network);
|
hasClearnet = hasClearnet || ['ipv4', 'ipv6'].includes(socket.network) || [4, 6].includes(isIP(socket.addr.split(':')[0]));
|
||||||
}
|
}
|
||||||
if (hasOnion && hasClearnet) {
|
if (hasOnion && hasClearnet) {
|
||||||
clearnetTorNodes++;
|
clearnetTorNodes++;
|
||||||
|
@ -127,22 +129,28 @@ class LightningStatsImporter {
|
||||||
|
|
||||||
if (channel.node1_policy !== undefined) { // Coming from the node
|
if (channel.node1_policy !== undefined) { // Coming from the node
|
||||||
for (const policy of [channel.node1_policy, channel.node2_policy]) {
|
for (const policy of [channel.node1_policy, channel.node2_policy]) {
|
||||||
if (policy && policy.fee_rate_milli_msat < 5000) {
|
if (policy && parseInt(policy.fee_rate_milli_msat, 10) < 5000) {
|
||||||
avgFeeRate += parseInt(policy.fee_rate_milli_msat, 10);
|
avgFeeRate += parseInt(policy.fee_rate_milli_msat, 10);
|
||||||
feeRates.push(parseInt(policy.fee_rate_milli_msat, 10));
|
feeRates.push(parseInt(policy.fee_rate_milli_msat, 10));
|
||||||
}
|
}
|
||||||
if (policy && policy.fee_base_msat < 5000) {
|
if (policy && parseInt(policy.fee_base_msat, 10) < 5000) {
|
||||||
avgBaseFee += parseInt(policy.fee_base_msat, 10);
|
avgBaseFee += parseInt(policy.fee_base_msat, 10);
|
||||||
baseFees.push(parseInt(policy.fee_base_msat, 10));
|
baseFees.push(parseInt(policy.fee_base_msat, 10));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // Coming from the historical import
|
} else { // Coming from the historical import
|
||||||
|
// @ts-ignore
|
||||||
if (channel.fee_rate_milli_msat < 5000) {
|
if (channel.fee_rate_milli_msat < 5000) {
|
||||||
|
// @ts-ignore
|
||||||
avgFeeRate += parseInt(channel.fee_rate_milli_msat, 10);
|
avgFeeRate += parseInt(channel.fee_rate_milli_msat, 10);
|
||||||
|
// @ts-ignore
|
||||||
feeRates.push(parseInt(channel.fee_rate_milli_msat), 10);
|
feeRates.push(parseInt(channel.fee_rate_milli_msat), 10);
|
||||||
}
|
}
|
||||||
|
// @ts-ignore
|
||||||
if (channel.fee_base_msat < 5000) {
|
if (channel.fee_base_msat < 5000) {
|
||||||
|
// @ts-ignore
|
||||||
avgBaseFee += parseInt(channel.fee_base_msat, 10);
|
avgBaseFee += parseInt(channel.fee_base_msat, 10);
|
||||||
|
// @ts-ignore
|
||||||
baseFees.push(parseInt(channel.fee_base_msat), 10);
|
baseFees.push(parseInt(channel.fee_base_msat), 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
|
||||||
import { Env, StateService } from '../../services/state.service';
|
import { Env, StateService } from '../../services/state.service';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { LanguageService } from 'src/app/services/language.service';
|
import { LanguageService } from 'src/app/services/language.service';
|
||||||
|
import { EnterpriseService } from 'src/app/services/enterprise.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-bisq-master-page',
|
selector: 'app-bisq-master-page',
|
||||||
|
@ -18,6 +19,7 @@ export class BisqMasterPageComponent implements OnInit {
|
||||||
constructor(
|
constructor(
|
||||||
private stateService: StateService,
|
private stateService: StateService,
|
||||||
private languageService: LanguageService,
|
private languageService: LanguageService,
|
||||||
|
private enterpriseService: EnterpriseService,
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
|
||||||
import { Env, StateService } from '../../services/state.service';
|
import { Env, StateService } from '../../services/state.service';
|
||||||
import { merge, Observable, of} from 'rxjs';
|
import { merge, Observable, of} from 'rxjs';
|
||||||
import { LanguageService } from 'src/app/services/language.service';
|
import { LanguageService } from 'src/app/services/language.service';
|
||||||
|
import { EnterpriseService } from 'src/app/services/enterprise.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-liquid-master-page',
|
selector: 'app-liquid-master-page',
|
||||||
|
@ -20,6 +21,7 @@ export class LiquidMasterPageComponent implements OnInit {
|
||||||
constructor(
|
constructor(
|
||||||
private stateService: StateService,
|
private stateService: StateService,
|
||||||
private languageService: LanguageService,
|
private languageService: LanguageService,
|
||||||
|
private enterpriseService: EnterpriseService,
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
|
@ -24,16 +24,16 @@ export class EnterpriseService {
|
||||||
this.subdomain = subdomain;
|
this.subdomain = subdomain;
|
||||||
this.fetchSubdomainInfo();
|
this.fetchSubdomainInfo();
|
||||||
this.disableSubnetworks();
|
this.disableSubnetworks();
|
||||||
} else if (document.location.hostname === 'mempool.space') {
|
} else {
|
||||||
this.insertMatomo();
|
this.insertMatomo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getSubdomain() {
|
getSubdomain(): string {
|
||||||
return this.subdomain;
|
return this.subdomain;
|
||||||
}
|
}
|
||||||
|
|
||||||
disableSubnetworks() {
|
disableSubnetworks(): void {
|
||||||
this.stateService.env.TESTNET_ENABLED = false;
|
this.stateService.env.TESTNET_ENABLED = false;
|
||||||
this.stateService.env.LIQUID_ENABLED = false;
|
this.stateService.env.LIQUID_ENABLED = false;
|
||||||
this.stateService.env.LIQUID_TESTNET_ENABLED = false;
|
this.stateService.env.LIQUID_TESTNET_ENABLED = false;
|
||||||
|
@ -41,7 +41,7 @@ export class EnterpriseService {
|
||||||
this.stateService.env.BISQ_ENABLED = false;
|
this.stateService.env.BISQ_ENABLED = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchSubdomainInfo() {
|
fetchSubdomainInfo(): void {
|
||||||
this.apiService.getEnterpriseInfo$(this.subdomain).subscribe((info) => {
|
this.apiService.getEnterpriseInfo$(this.subdomain).subscribe((info) => {
|
||||||
this.info = info;
|
this.info = info;
|
||||||
this.insertMatomo(info.site_id);
|
this.insertMatomo(info.site_id);
|
||||||
|
@ -54,14 +54,38 @@ export class EnterpriseService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
insertMatomo(siteId = 5) {
|
insertMatomo(siteId?: number): void {
|
||||||
let statsUrl = '//stats.mempool.space/';
|
let statsUrl = '//stats.mempool.space/';
|
||||||
if (this.document.location.hostname === 'liquid.network') {
|
|
||||||
statsUrl = '//stats.liquid.network/';
|
if (!siteId) {
|
||||||
siteId = 8;
|
switch (this.document.location.hostname) {
|
||||||
} else if (this.document.location.hostname === 'bisq.markets') {
|
case 'mempool.space':
|
||||||
statsUrl = '//stats.bisq.markets/';
|
statsUrl = '//stats.mempool.space/';
|
||||||
siteId = 7;
|
siteId = 5;
|
||||||
|
break;
|
||||||
|
case 'mempool.ninja':
|
||||||
|
statsUrl = '//stats.mempool.space/';
|
||||||
|
siteId = 4;
|
||||||
|
break;
|
||||||
|
case 'liquid.network':
|
||||||
|
siteId = 8;
|
||||||
|
statsUrl = '//stats.liquid.network/';
|
||||||
|
break;
|
||||||
|
case 'liquid.place':
|
||||||
|
siteId = 10;
|
||||||
|
statsUrl = '//stats.liquid.network/';
|
||||||
|
break;
|
||||||
|
case 'bisq.markets':
|
||||||
|
siteId = 7;
|
||||||
|
statsUrl = '//stats.bisq.markets/';
|
||||||
|
break;
|
||||||
|
case 'bisq.ninja':
|
||||||
|
statsUrl = '//stats.bisq.markets/';
|
||||||
|
siteId = 11;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|
Loading…
Add table
Reference in a new issue