From 77686821bae49f31a483facddc36eea40049927a Mon Sep 17 00:00:00 2001 From: Mononaut Date: Fri, 17 Feb 2023 10:12:33 -0600 Subject: [PATCH 1/7] Raise production memory limits Increases maxmempool production bitcoin.conf setting to 2GB, and raises `npm run start-production` nodejs memory limit to 8GB --- backend/package.json | 2 +- production/bitcoin.conf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/package.json b/backend/package.json index da72386fe..9c1b3a12a 100644 --- a/backend/package.json +++ b/backend/package.json @@ -27,7 +27,7 @@ "package": "npm run build && rm -rf package && mv dist package && mv node_modules package && npm run package-rm-build-deps", "package-rm-build-deps": "(cd package/node_modules; rm -r typescript @typescript-eslint)", "start": "node --max-old-space-size=2048 dist/index.js", - "start-production": "node --max-old-space-size=4096 dist/index.js", + "start-production": "node --max-old-space-size=16384 dist/index.js", "test": "./node_modules/.bin/jest --coverage", "lint": "./node_modules/.bin/eslint . --ext .ts", "lint:fix": "./node_modules/.bin/eslint . --ext .ts --fix", diff --git a/production/bitcoin.conf b/production/bitcoin.conf index 99fbaeed1..46ab41b20 100644 --- a/production/bitcoin.conf +++ b/production/bitcoin.conf @@ -5,7 +5,7 @@ listen=1 discover=1 par=16 dbcache=8192 -maxmempool=1337 +maxmempool=4096 mempoolexpiry=999999 maxconnections=42 onion=127.0.0.1:9050 From 8f51e20b2e944fde17ddefd587703e6b744540f9 Mon Sep 17 00:00:00 2001 From: softsimon Date: Tue, 21 Feb 2023 17:14:51 +0400 Subject: [PATCH 2/7] Fixes a syntax error with certain keywords --- backend/src/api/explorer/nodes.api.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/src/api/explorer/nodes.api.ts b/backend/src/api/explorer/nodes.api.ts index d292aa2e3..0d641d3cf 100644 --- a/backend/src/api/explorer/nodes.api.ts +++ b/backend/src/api/explorer/nodes.api.ts @@ -362,7 +362,12 @@ class NodesApi { public async $searchNodeByPublicKeyOrAlias(search: string) { try { const publicKeySearch = search.replace('%', '') + '%'; - const aliasSearch = search.replace(/[-_.]/g, ' ').replace(/[^a-zA-Z0-9 ]/g, '').split(' ').map((search) => '+' + search + '*').join(' '); + const aliasSearch = search + .replace(/[-_.]/g, ' ') + .replace(/[^a-zA-Z0-9 ]/g, '') + .split(' ') + .filter(key => key.length) + .map((search) => '+' + search + '*').join(' '); const query = `SELECT public_key, alias, capacity, channels, status FROM nodes WHERE public_key LIKE ? OR MATCH alias_search AGAINST (? IN BOOLEAN MODE) ORDER BY capacity DESC LIMIT 10`; const [rows]: any = await DB.query(query, [publicKeySearch, aliasSearch]); return rows; From 32b38e6cd1a4748b8f99b26bf9c8fe6f0b678348 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Tue, 21 Feb 2023 22:07:12 -0600 Subject: [PATCH 3/7] increase size of mempool_byte_weight db column --- backend/src/api/database-migration.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/src/api/database-migration.ts b/backend/src/api/database-migration.ts index 66216c64a..a0200c98c 100644 --- a/backend/src/api/database-migration.ts +++ b/backend/src/api/database-migration.ts @@ -7,7 +7,7 @@ import cpfpRepository from '../repositories/CpfpRepository'; import { RowDataPacket } from 'mysql2'; class DatabaseMigration { - private static currentVersion = 52; + private static currentVersion = 53; private queryTimeout = 3600_000; private statisticsAddedIndexed = false; private uniqueLogs: string[] = []; @@ -468,6 +468,11 @@ class DatabaseMigration { logger.warn('' + (e instanceof Error ? e.message : e)); } } + + if (databaseSchemaVersion < 53) { + await this.$executeQuery('ALTER TABLE statistics MODIFY mempool_byte_weight bigint(20) UNSIGNED NOT NULL'); + await this.updateToSchemaVersion(53); + } } /** From 437350aaff352ec504053f9f333648b13cbbfff6 Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Wed, 22 Feb 2023 14:06:08 +0900 Subject: [PATCH 4/7] Unknown pool color #FDD835 --- frontend/src/app/app.constants.ts | 2 +- .../hashrates-chart-pools/hashrate-chart-pools.component.ts | 2 +- .../src/app/components/pool-ranking/pool-ranking.component.ts | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/app.constants.ts b/frontend/src/app/app.constants.ts index 8a954166e..779eab62e 100644 --- a/frontend/src/app/app.constants.ts +++ b/frontend/src/app/app.constants.ts @@ -72,7 +72,7 @@ export const chartColors = [ ]; export const poolsColor = { - 'unknown': '#9C9C9C', + 'unknown': '#FDD835', }; export const feeLevels = [1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 30, 40, 50, 60, 70, 80, 90, 100, 125, 150, 175, 200, diff --git a/frontend/src/app/components/hashrates-chart-pools/hashrate-chart-pools.component.ts b/frontend/src/app/components/hashrates-chart-pools/hashrate-chart-pools.component.ts index df7780fee..e7e3685d3 100644 --- a/frontend/src/app/components/hashrates-chart-pools/hashrate-chart-pools.component.ts +++ b/frontend/src/app/components/hashrates-chart-pools/hashrate-chart-pools.component.ts @@ -173,7 +173,7 @@ export class HashrateChartPoolsComponent implements OnInit { this.chartOptions = { title: title, animation: false, - color: chartColors, + color: chartColors.filter(color => color !== '#FDD835'), grid: { right: this.right, left: this.left, diff --git a/frontend/src/app/components/pool-ranking/pool-ranking.component.ts b/frontend/src/app/components/pool-ranking/pool-ranking.component.ts index 8284d81da..a3f23c031 100644 --- a/frontend/src/app/components/pool-ranking/pool-ranking.component.ts +++ b/frontend/src/app/components/pool-ranking/pool-ranking.component.ts @@ -4,7 +4,6 @@ import { ActivatedRoute, Router } from '@angular/router'; import { EChartsOption, PieSeriesOption } from 'echarts'; import { concat, Observable } from 'rxjs'; import { map, share, startWith, switchMap, tap } from 'rxjs/operators'; -import { SinglePoolStats } from '../../interfaces/node-api.interface'; import { SeoService } from '../../services/seo.service'; import { StorageService } from '../..//services/storage.service'; import { MiningService, MiningStats } from '../../services/mining.service'; @@ -220,7 +219,7 @@ export class PoolRankingComponent implements OnInit { this.chartOptions = { animation: false, - color: chartColors, + color: chartColors.filter(color => color !== '#FDD835'), tooltip: { trigger: 'item', textStyle: { From b6792784e85caac81a65d2a408881b7fc759c51d Mon Sep 17 00:00:00 2001 From: softsimon Date: Wed, 22 Feb 2023 10:19:19 +0400 Subject: [PATCH 5/7] Adding regex comments. --- backend/src/api/explorer/nodes.api.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/api/explorer/nodes.api.ts b/backend/src/api/explorer/nodes.api.ts index 0d641d3cf..36bbf26d2 100644 --- a/backend/src/api/explorer/nodes.api.ts +++ b/backend/src/api/explorer/nodes.api.ts @@ -363,8 +363,8 @@ class NodesApi { try { const publicKeySearch = search.replace('%', '') + '%'; const aliasSearch = search - .replace(/[-_.]/g, ' ') - .replace(/[^a-zA-Z0-9 ]/g, '') + .replace(/[-_.]/g, ' ') // Replace all -_. characters with empty space. Eg: "ln.nicehash" becomes "ln nicehash". + .replace(/[^a-zA-Z0-9 ]/g, '') // Remove all special characters and keep just A to Z, 0 to 9. .split(' ') .filter(key => key.length) .map((search) => '+' + search + '*').join(' '); From 2246a6f3cefba9f789f9192d533a29afab8d5bba Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Wed, 22 Feb 2023 20:42:32 +0900 Subject: [PATCH 6/7] Fix 'NaN' price for unconfirmed transaction since we have no block timestamp --- frontend/src/app/services/price.service.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/src/app/services/price.service.ts b/frontend/src/app/services/price.service.ts index 3320280e9..fe6d67bb6 100644 --- a/frontend/src/app/services/price.service.ts +++ b/frontend/src/app/services/price.service.ts @@ -93,6 +93,10 @@ export class PriceService { * @param blockTimestamp */ getPriceForTimestamp(blockTimestamp: number): Price | null { + if (!blockTimestamp) { + return undefined; + } + const priceTimestamps = Object.keys(this.historicalPrice.prices); priceTimestamps.push(Number.MAX_SAFE_INTEGER.toString()); priceTimestamps.sort().reverse(); From 10bfb512159f34c12ea9cf8a6948fa20a970a1b0 Mon Sep 17 00:00:00 2001 From: wiz Date: Thu, 23 Feb 2023 13:37:09 +0900 Subject: [PATCH 7/7] Add simon's comment to $searchNodeByPublicKeyOrAlias() --- backend/src/api/explorer/nodes.api.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/api/explorer/nodes.api.ts b/backend/src/api/explorer/nodes.api.ts index 36bbf26d2..b3f83faa6 100644 --- a/backend/src/api/explorer/nodes.api.ts +++ b/backend/src/api/explorer/nodes.api.ts @@ -368,6 +368,7 @@ class NodesApi { .split(' ') .filter(key => key.length) .map((search) => '+' + search + '*').join(' '); + // %keyword% is wildcard search and can't be indexed so it's slower as the node database grow. keyword% can be indexed but then you can't search for "Nicehash" and get result for ln.nicehash.com. So we use fulltext index for words "ln, nicehash, com" and nicehash* will find it instantly. const query = `SELECT public_key, alias, capacity, channels, status FROM nodes WHERE public_key LIKE ? OR MATCH alias_search AGAINST (? IN BOOLEAN MODE) ORDER BY capacity DESC LIMIT 10`; const [rows]: any = await DB.query(query, [publicKeySearch, aliasSearch]); return rows;