From 2872d2e29903b98b9da22a91b6a6a0bb75401255 Mon Sep 17 00:00:00 2001 From: nymkappa Date: Fri, 15 Jul 2022 11:03:59 +0200 Subject: [PATCH 1/4] Refactor BlocksSummariesRepository::$saveSummary --- backend/src/api/blocks.ts | 2 +- backend/src/api/websocket-handler.ts | 9 ++++++--- .../src/repositories/BlocksSummariesRepository.ts | 14 +++++++------- .../app/components/block-overview-graph/tx-view.ts | 4 +--- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/backend/src/api/blocks.ts b/backend/src/api/blocks.ts index 30f9fbf78..e40977c6c 100644 --- a/backend/src/api/blocks.ts +++ b/backend/src/api/blocks.ts @@ -578,7 +578,7 @@ class Blocks { // Index the response if needed if (Common.blocksSummariesIndexingEnabled() === true) { - await BlocksSummariesRepository.$saveSummary(block.height, summary, null); + await BlocksSummariesRepository.$saveSummary({height: block.height, mined: summary}); } return summary.transactions; diff --git a/backend/src/api/websocket-handler.ts b/backend/src/api/websocket-handler.ts index dee44ba63..4896ee058 100644 --- a/backend/src/api/websocket-handler.ts +++ b/backend/src/api/websocket-handler.ts @@ -451,9 +451,12 @@ class WebsocketHandler { value: tx.value, }; }); - BlocksSummariesRepository.$saveSummary(block.height, null, { - id: block.id, - transactions: stripped + BlocksSummariesRepository.$saveSummary({ + height: block.height, + template: { + id: block.id, + transactions: stripped + } }); BlocksAuditsRepository.$saveAudit({ diff --git a/backend/src/repositories/BlocksSummariesRepository.ts b/backend/src/repositories/BlocksSummariesRepository.ts index 2f47f7a35..28b3cc7eb 100644 --- a/backend/src/repositories/BlocksSummariesRepository.ts +++ b/backend/src/repositories/BlocksSummariesRepository.ts @@ -17,18 +17,18 @@ class BlocksSummariesRepository { return undefined; } - public async $saveSummary(height: number, mined: BlockSummary | null = null, template: BlockSummary | null = null) { - const blockId = mined?.id ?? template?.id; + public async $saveSummary(params: { height: number, mined?: BlockSummary, template?: BlockSummary}) { + const blockId = params.mined?.id ?? params.template?.id; try { const [dbSummary]: any[] = await DB.query(`SELECT * FROM blocks_summaries WHERE id = "${blockId}"`); if (dbSummary.length === 0) { // First insertion await DB.query(`INSERT INTO blocks_summaries VALUE (?, ?, ?, ?)`, [ - height, blockId, JSON.stringify(mined?.transactions ?? []), JSON.stringify(template?.transactions ?? []) + params.height, blockId, JSON.stringify(params.mined?.transactions ?? []), JSON.stringify(params.template?.transactions ?? []) ]); - } else if (mined !== null) { // Update mined block summary - await DB.query(`UPDATE blocks_summaries SET transactions = ? WHERE id = "${mined.id}"`, [JSON.stringify(mined?.transactions)]); - } else if (template !== null) { // Update template block summary - await DB.query(`UPDATE blocks_summaries SET template = ? WHERE id = "${template.id}"`, [JSON.stringify(template?.transactions)]); + } else if (params.mined !== undefined) { // Update mined block summary + await DB.query(`UPDATE blocks_summaries SET transactions = ? WHERE id = "${params.mined.id}"`, [JSON.stringify(params.mined.transactions)]); + } else if (params.template !== undefined) { // Update template block summary + await DB.query(`UPDATE blocks_summaries SET template = ? WHERE id = "${params.template.id}"`, [JSON.stringify(params.template?.transactions)]); } } catch (e: any) { if (e.errno === 1062) { // ER_DUP_ENTRY - This scenario is possible upon node backend restart diff --git a/frontend/src/app/components/block-overview-graph/tx-view.ts b/frontend/src/app/components/block-overview-graph/tx-view.ts index edcbf2f58..c0b980d5c 100644 --- a/frontend/src/app/components/block-overview-graph/tx-view.ts +++ b/frontend/src/app/components/block-overview-graph/tx-view.ts @@ -143,9 +143,7 @@ export default class TxView implements TransactionStripped { getColor(): Color { // Block audit - if (this.status === 'found') { - // return hexToColor('1a4987'); - } else if (this.status === 'missing') { + if (this.status === 'missing') { return hexToColor('039BE5'); } else if (this.status === 'added') { return hexToColor('D81B60'); From 3dc37dc34dad41995f2f6beed6a63b505f03c51a Mon Sep 17 00:00:00 2001 From: nymkappa Date: Tue, 19 Jul 2022 08:00:11 +0200 Subject: [PATCH 2/4] Fix block predition graph x axis labels --- .../block-prediction-graph/block-prediction-graph.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/app/components/block-prediction-graph/block-prediction-graph.component.ts b/frontend/src/app/components/block-prediction-graph/block-prediction-graph.component.ts index c708c7574..e88dc07be 100644 --- a/frontend/src/app/components/block-prediction-graph/block-prediction-graph.component.ts +++ b/frontend/src/app/components/block-prediction-graph/block-prediction-graph.component.ts @@ -156,7 +156,7 @@ export class BlockPredictionGraphComponent implements OnInit { type: 'category', axisLine: { onZero: true }, axisLabel: { - formatter: val => formatterXAxisTimeCategory(this.locale, this.timespan, parseInt(val, 10)), + formatter: val => formatterXAxisTimeCategory(this.locale, this.timespan, parseInt(val, 10) * 1000), align: 'center', fontSize: 11, lineHeight: 12, From 3e1e47c49a04e4ffe975350dd051e3d368dca57b Mon Sep 17 00:00:00 2001 From: softsimon Date: Wed, 20 Jul 2022 18:29:19 +0200 Subject: [PATCH 3/4] Remove gitignore json wildcard --- backend/.gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/.gitignore b/backend/.gitignore index 5476d633c..67fb162c6 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -1,9 +1,9 @@ # See http://help.github.com/ignore-files/ for more about ignoring files. # production config and external assets -*.json -!mempool-config.sample.json +mempool-config.json +pools.json icons.json # compiled output From a5f1ba92e4fa1f74b2cf33e8a2f453e82239b012 Mon Sep 17 00:00:00 2001 From: softsimon Date: Wed, 20 Jul 2022 19:30:00 +0200 Subject: [PATCH 4/4] Always show taproot button refs #2107 --- .../app/components/tx-features/tx-features.component.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/components/tx-features/tx-features.component.html b/frontend/src/app/components/tx-features/tx-features.component.html index 46856a7c7..b5463185e 100644 --- a/frontend/src/app/components/tx-features/tx-features.component.html +++ b/frontend/src/app/components/tx-features/tx-features.component.html @@ -5,6 +5,9 @@ SegWit -Taproot +Taproot + + Taproot + RBF RBF