Merge branch 'master' into nymkappa/feature/fee-range-chart

This commit is contained in:
wiz 2022-04-23 04:44:03 +00:00 committed by GitHub
commit ed495cc019
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 98 additions and 57 deletions

View File

@ -77,7 +77,7 @@ export class Common {
}; };
} }
static sleep(ms: number): Promise<void> { static sleep$(ms: number): Promise<void> {
return new Promise((resolve) => { return new Promise((resolve) => {
setTimeout(() => { setTimeout(() => {
resolve(); resolve();

View File

@ -1,8 +1,7 @@
import config from '../config'; import config from '../config';
import DB from '../database'; import DB from '../database';
import logger from '../logger'; import logger from '../logger';
import { Common } from './common';
const sleep = (ms: number) => new Promise(res => setTimeout(res, ms));
class DatabaseMigration { class DatabaseMigration {
private static currentVersion = 17; private static currentVersion = 17;
@ -25,7 +24,7 @@ class DatabaseMigration {
await this.$createMigrationStateTable(); await this.$createMigrationStateTable();
} catch (e) { } catch (e) {
logger.err('MIGRATIONS: Unable to create `state` table, aborting in 10 seconds. ' + e); logger.err('MIGRATIONS: Unable to create `state` table, aborting in 10 seconds. ' + e);
await sleep(10000); await Common.sleep$(10000);
process.exit(-1); process.exit(-1);
} }
logger.debug('MIGRATIONS: `state` table initialized.'); logger.debug('MIGRATIONS: `state` table initialized.');
@ -36,7 +35,7 @@ class DatabaseMigration {
databaseSchemaVersion = await this.$getSchemaVersionFromDatabase(); databaseSchemaVersion = await this.$getSchemaVersionFromDatabase();
} catch (e) { } catch (e) {
logger.err('MIGRATIONS: Unable to get current database migration version, aborting in 10 seconds. ' + e); logger.err('MIGRATIONS: Unable to get current database migration version, aborting in 10 seconds. ' + e);
await sleep(10000); await Common.sleep$(10000);
process.exit(-1); process.exit(-1);
} }
@ -52,7 +51,7 @@ class DatabaseMigration {
await this.$createMissingTablesAndIndexes(databaseSchemaVersion); await this.$createMissingTablesAndIndexes(databaseSchemaVersion);
} catch (e) { } catch (e) {
logger.err('MIGRATIONS: Unable to create required tables, aborting in 10 seconds. ' + e); logger.err('MIGRATIONS: Unable to create required tables, aborting in 10 seconds. ' + e);
await sleep(10000); await Common.sleep$(10000);
process.exit(-1); process.exit(-1);
} }

View File

@ -1,5 +1,4 @@
import * as fs from 'fs'; import * as fs from 'fs';
import config from '../../config';
import logger from '../../logger'; import logger from '../../logger';
class Icons { class Icons {

View File

@ -85,16 +85,16 @@ class Server {
this.setUpWebsocketHandling(); this.setUpWebsocketHandling();
await syncAssets.syncAssets(); await syncAssets.syncAssets$();
diskCache.loadMempoolCache(); diskCache.loadMempoolCache();
if (config.DATABASE.ENABLED) { if (config.DATABASE.ENABLED) {
await DB.checkDbConnection(); await DB.checkDbConnection();
try { try {
if (process.env.npm_config_reindex != undefined) { // Re-index requests if (process.env.npm_config_reindex !== undefined) { // Re-index requests
const tables = process.env.npm_config_reindex.split(','); const tables = process.env.npm_config_reindex.split(',');
logger.warn(`Indexed data for "${process.env.npm_config_reindex}" tables will be erased in 5 seconds (using '--reindex')`); logger.warn(`Indexed data for "${process.env.npm_config_reindex}" tables will be erased in 5 seconds (using '--reindex')`);
await Common.sleep(5000); await Common.sleep$(5000);
await databaseMigration.$truncateIndexedData(tables); await databaseMigration.$truncateIndexedData(tables);
} }
await databaseMigration.$initializeOrMigrateDatabase(); await databaseMigration.$initializeOrMigrateDatabase();

View File

@ -9,55 +9,69 @@ const PATH = './';
class SyncAssets { class SyncAssets {
constructor() { } constructor() { }
public async syncAssets() { public async syncAssets$() {
for (const url of config.MEMPOOL.EXTERNAL_ASSETS) { for (const url of config.MEMPOOL.EXTERNAL_ASSETS) {
await this.downloadFile(url); try {
await this.downloadFile$(url);
} catch (e) {
throw new Error(`Failed to download external asset. ` + (e instanceof Error ? e.message : e));
}
} }
} }
private async downloadFile(url: string) { private async downloadFile$(url: string) {
const fileName = url.split('/').slice(-1)[0]; return new Promise((resolve, reject) => {
const fileName = url.split('/').slice(-1)[0];
try { try {
if (config.SOCKS5PROXY.ENABLED) { if (config.SOCKS5PROXY.ENABLED) {
let socksOptions: any = { const socksOptions: any = {
agentOptions: { agentOptions: {
keepAlive: true, keepAlive: true,
}, },
host: config.SOCKS5PROXY.HOST, host: config.SOCKS5PROXY.HOST,
port: config.SOCKS5PROXY.PORT port: config.SOCKS5PROXY.PORT
}; };
if (config.SOCKS5PROXY.USERNAME && config.SOCKS5PROXY.PASSWORD) { if (config.SOCKS5PROXY.USERNAME && config.SOCKS5PROXY.PASSWORD) {
socksOptions.username = config.SOCKS5PROXY.USERNAME; socksOptions.username = config.SOCKS5PROXY.USERNAME;
socksOptions.password = config.SOCKS5PROXY.PASSWORD; socksOptions.password = config.SOCKS5PROXY.PASSWORD;
}
const agent = new SocksProxyAgent(socksOptions);
logger.info(`Downloading external asset ${fileName} over the Tor network...`);
return axios.get(url, {
httpAgent: agent,
httpsAgent: agent,
responseType: 'stream',
timeout: 30000
}).then(function (response) {
const writer = fs.createWriteStream(PATH + fileName);
writer.on('finish', () => {
logger.info(`External asset ${fileName} saved to ${PATH + fileName}`);
resolve(0);
});
response.data.pipe(writer);
});
} else {
logger.info(`Downloading external asset ${fileName} over clearnet...`);
return axios.get(url, {
responseType: 'stream',
timeout: 30000
}).then(function (response) {
const writer = fs.createWriteStream(PATH + fileName);
writer.on('finish', () => {
logger.info(`External asset ${fileName} saved to ${PATH + fileName}`);
resolve(0);
});
response.data.pipe(writer);
});
} }
} catch (e: any) {
const agent = new SocksProxyAgent(socksOptions); reject(e);
logger.info(`Downloading external asset ${fileName} over the Tor network...`);
await axios.get(url, {
httpAgent: agent,
httpsAgent: agent,
responseType: 'stream',
timeout: 30000
}).then(function (response) {
response.data.pipe(fs.createWriteStream(PATH + fileName));
logger.info(`External asset ${fileName} saved to ${PATH + fileName}`);
});
} else {
logger.info(`Downloading external asset ${fileName} over clearnet...`);
await axios.get(url, {
responseType: 'stream',
timeout: 30000
}).then(function (response) {
response.data.pipe(fs.createWriteStream(PATH + fileName));
logger.info(`External asset ${fileName} saved to ${PATH + fileName}`);
});
} }
} catch (e: any) { });
throw new Error(`Failed to download external asset. ` + e);
}
} }
} }

View File

@ -226,6 +226,10 @@
<img class="image" src="/resources/profile/phoenix.jpg" /> <img class="image" src="/resources/profile/phoenix.jpg" />
<span>Phoenix</span> <span>Phoenix</span>
</a> </a>
<a href="https://github.com/layer2tech/mercury-wallet" target="_blank" title="Mercury Wallet">
<img class="image" src="/resources/profile/mercury.svg" />
<span>Mercury</span>
</a>
<a href="https://github.com/muun/apollo" target="_blank" title="Muun Wallet"> <a href="https://github.com/muun/apollo" target="_blank" title="Muun Wallet">
<img class="image" src="/resources/profile/muun.png" /> <img class="image" src="/resources/profile/muun.png" />
<span>Muun</span> <span>Muun</span>

View File

@ -185,6 +185,6 @@
} }
.community-integrations-sponsor { .community-integrations-sponsor {
max-width: 750px; max-width: 830px;
margin: auto; margin: auto;
} }

View File

@ -64,7 +64,7 @@
</div> </div>
<div class="w-100 d-block d-md-none"></div> <div class="w-100 d-block d-md-none"></div>
<div class="col icon-holder"> <div class="col icon-holder">
<img *ngIf="!imageError; else defaultIcon" class="assetIcon" [src]="'https://liquid.network/api/v1/asset/' + asset.asset_id + '/icon'" (error)="imageError = true"> <img *ngIf="!imageError; else defaultIcon" class="assetIcon" [src]="'/api/v1/asset/' + asset.asset_id + '/icon'" (error)="imageError = true">
<ng-template #defaultIcon> <ng-template #defaultIcon>
<fa-icon class="defaultIcon" [icon]="['fas', 'database']" [fixedWidth]="true" size="8x"></fa-icon> <fa-icon class="defaultIcon" [icon]="['fas', 'database']" [fixedWidth]="true" size="8x"></fa-icon>
</ng-template> </ng-template>

View File

@ -15,7 +15,7 @@
<div *ngFor="let asset of group.assets"> <div *ngFor="let asset of group.assets">
<div class="card"> <div class="card">
<a [routerLink]="['/assets/asset' | relativeUrl, asset.asset_id]"> <a [routerLink]="['/assets/asset' | relativeUrl, asset.asset_id]">
<img class="assetIcon" [src]="'https://liquid.network/api/v1/asset/' + asset.asset_id + '/icon'"> <img class="assetIcon" [src]="'/api/v1/asset/' + asset.asset_id + '/icon'">
</a> </a>
<div class="title"> <div class="title">
<a [routerLink]="['/assets/asset/' | relativeUrl, asset.asset_id]">{{ asset.name }}</a> <a [routerLink]="['/assets/asset/' | relativeUrl, asset.asset_id]">{{ asset.name }}</a>

View File

@ -3,14 +3,14 @@
<div class="card" *ngFor="let group of featured"> <div class="card" *ngFor="let group of featured">
<ng-template [ngIf]="group.assets" [ngIfElse]="singleAsset"> <ng-template [ngIf]="group.assets" [ngIfElse]="singleAsset">
<a [routerLink]="['/assets/group' | relativeUrl, group.id]"> <a [routerLink]="['/assets/group' | relativeUrl, group.id]">
<img class="assetIcon" [src]="'https://liquid.network/api/v1/asset/' + group.assets[0] + '/icon'"> <img class="assetIcon" [src]="'/api/v1/asset/' + group.assets[0] + '/icon'">
</a> </a>
<div class="title"><a [routerLink]="['/assets/group' | relativeUrl, group.id]">{{ group.name }}</a></div> <div class="title"><a [routerLink]="['/assets/group' | relativeUrl, group.id]">{{ group.name }}</a></div>
<div class="sub-title" i18n>Group of {{ group.assets.length | number }} assets</div> <div class="sub-title" i18n>Group of {{ group.assets.length | number }} assets</div>
</ng-template> </ng-template>
<ng-template #singleAsset> <ng-template #singleAsset>
<a [routerLink]="['/assets/asset/' | relativeUrl, group.asset]"> <a [routerLink]="['/assets/asset/' | relativeUrl, group.asset]">
<img class="assetIcon" [src]="'https://liquid.network/api/v1/asset/' + group.asset + '/icon'"> <img class="assetIcon" [src]="'/api/v1/asset/' + group.asset + '/icon'">
</a> </a>
<div class="title"> <div class="title">
<a [routerLink]="['/assets/asset/' | relativeUrl, group.asset]">{{ group.name }}</a> <a [routerLink]="['/assets/asset/' | relativeUrl, group.asset]">{{ group.name }}</a>

View File

@ -79,7 +79,7 @@
<tr *ngFor="let group of featuredAssets"> <tr *ngFor="let group of featuredAssets">
<td class="asset-icon"> <td class="asset-icon">
<a [routerLink]="['/assets/asset/' | relativeUrl, group.asset]"> <a [routerLink]="['/assets/asset/' | relativeUrl, group.asset]">
<img class="assetIcon" [src]="'https://liquid.network/api/v1/asset/' + group.asset + '/icon'"> <img class="assetIcon" [src]="'/api/v1/asset/' + group.asset + '/icon'">
</a> </a>
</td> </td>
<td class="asset-title"> <td class="asset-title">

View File

@ -0,0 +1,25 @@
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 337 337">
<defs>
<style>
.cls-1 {
fill: #0054f4;
}
.cls-2 {
fill: #009cff;
}
.cls-3 {
fill: #0085c7;
}
</style>
</defs>
<g>
<path class="cls-1" d="M102.48,176l-.12.19a7.64,7.64,0,1,1-13.23-7.64l19.73-34.25a5,5,0,0,0-4.31-7.45H56.6c-10.05-.4-17.29,11-12.5,20l35,74.73h0a35.38,35.38,0,0,0,51.07,14.84Z"/>
<path class="cls-1" d="M294.41,228a14.22,14.22,0,0,0-1.47-6.11l-35-74.64h0a35.38,35.38,0,0,0-40.41-19.41l-.18,0,16.48,35.88a7.64,7.64,0,0,1,11.1,10l-35,60.58a5,5,0,0,0,4.37,7.57h66.11A13.79,13.79,0,0,0,294.41,228Z"/>
<g>
<path class="cls-2" d="M197.22,50.31c-.78-2-2.94-5.79-5.85-7-5-2.5-11.91-1.08-14.74,4.1l-45.84,79.43h0l-28.43,49.34a7.63,7.63,0,0,1-13.49-.5l51.69,112.55c4.22,9,16.09,8.77,20.59.19L188,242h0l43.74-75.79a7.63,7.63,0,0,1,13.67.93l-46-112Z"/>
<path class="cls-3" d="M245.49,167.35s0,0,0,0h0Z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB