From 3608fa6f199cc3d396469c86a8a8d5b7e91ed7b4 Mon Sep 17 00:00:00 2001 From: Antoni Spaanderman <56turtle56@gmail.com> Date: Wed, 19 Jan 2022 16:58:56 +0100 Subject: [PATCH 01/44] load blocks with height under INITIAL_BLOCKS_AMOUNT --- backend/src/api/blocks.ts | 14 ++++++++------ backend/src/config.ts | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/backend/src/api/blocks.ts b/backend/src/api/blocks.ts index 1043c344f..3d50e1684 100644 --- a/backend/src/api/blocks.ts +++ b/backend/src/api/blocks.ts @@ -34,7 +34,7 @@ class Blocks { const blockHeightTip = await bitcoinApi.$getBlockHeightTip(); if (this.blocks.length === 0) { - this.currentBlockHeight = blockHeightTip - config.MEMPOOL.INITIAL_BLOCKS_AMOUNT; + this.currentBlockHeight = Math.max(blockHeightTip - config.MEMPOOL.INITIAL_BLOCKS_AMOUNT, -1); } else { this.currentBlockHeight = this.blocks[this.blocks.length - 1].height; } @@ -53,17 +53,19 @@ class Blocks { this.lastDifficultyAdjustmentTime = block.timestamp; this.currentDifficulty = block.difficulty; - const previousPeriodBlockHash = await bitcoinApi.$getBlockHash(blockHeightTip - heightDiff - 2016); - const previousPeriodBlock = await bitcoinApi.$getBlock(previousPeriodBlockHash); - this.previousDifficultyRetarget = (block.difficulty - previousPeriodBlock.difficulty) / previousPeriodBlock.difficulty * 100; - logger.debug(`Initial difficulty adjustment data set.`); + if (blockHeightTip - heightDiff - 2016 >= 0) { + const previousPeriodBlockHash = await bitcoinApi.$getBlockHash(blockHeightTip - heightDiff - 2016); + const previousPeriodBlock = await bitcoinApi.$getBlock(previousPeriodBlockHash); + this.previousDifficultyRetarget = (block.difficulty - previousPeriodBlock.difficulty) / previousPeriodBlock.difficulty * 100; + logger.debug(`Initial difficulty adjustment data set.`); + } } else { logger.debug(`Blockchain headers (${blockchainInfo.headers}) and blocks (${blockchainInfo.blocks}) not in sync. Waiting...`); } } while (this.currentBlockHeight < blockHeightTip) { - if (this.currentBlockHeight === 0) { + if (this.currentBlockHeight < blockHeightTip - config.MEMPOOL.INITIAL_BLOCKS_AMOUNT) { this.currentBlockHeight = blockHeightTip; } else { this.currentBlockHeight++; diff --git a/backend/src/config.ts b/backend/src/config.ts index 4c2888834..13ad224a1 100644 --- a/backend/src/config.ts +++ b/backend/src/config.ts @@ -2,7 +2,7 @@ const configFile = require('../mempool-config.json'); interface IConfig { MEMPOOL: { - NETWORK: 'mainnet' | 'testnet' | 'signet' | 'liquid' | 'liquidtestnet'; + NETWORK: 'mainnet' | 'testnet' | 'signet' | 'regtest' | 'liquid' | 'liquidtestnet'; BACKEND: 'esplora' | 'electrum' | 'none'; HTTP_PORT: number; SPAWN_CLUSTER_PROCS: number; From e59f610a75490b90e368f2d5e5b8c0b50ff76c22 Mon Sep 17 00:00:00 2001 From: Antoni Spaanderman <56turtle56@gmail.com> Date: Wed, 19 Jan 2022 17:11:35 +0100 Subject: [PATCH 02/44] display genesis block --- frontend/src/app/services/state.service.ts | 2 +- frontend/src/app/services/websocket.service.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/services/state.service.ts b/frontend/src/app/services/state.service.ts index 8050e4286..eebde80ea 100644 --- a/frontend/src/app/services/state.service.ts +++ b/frontend/src/app/services/state.service.ts @@ -69,7 +69,7 @@ export class StateService { network = ''; blockVSize: number; env: Env; - latestBlockHeight = 0; + latestBlockHeight = -1; networkChanged$ = new ReplaySubject(1); blocks$: ReplaySubject<[Block, boolean]>; diff --git a/frontend/src/app/services/websocket.service.ts b/frontend/src/app/services/websocket.service.ts index dc65cf8f7..2c8944baf 100644 --- a/frontend/src/app/services/websocket.service.ts +++ b/frontend/src/app/services/websocket.service.ts @@ -67,7 +67,7 @@ export class WebsocketService { clearTimeout(this.onlineCheckTimeout); clearTimeout(this.onlineCheckTimeoutTwo); - this.stateService.latestBlockHeight = 0; + this.stateService.latestBlockHeight = -1; this.websocketSubject.complete(); this.subscription.unsubscribe(); From 4bf167d3e15cb45d606e6a4d53122c3de6584d5b Mon Sep 17 00:00:00 2001 From: Antoni Spaanderman <56turtle56@gmail.com> Date: Thu, 20 Jan 2022 15:57:53 +0100 Subject: [PATCH 03/44] fixed arrow not pointing to genesis block --- .../blockchain-blocks/blockchain-blocks.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.ts b/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.ts index 665822bd5..6c2babd5a 100644 --- a/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.ts +++ b/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.ts @@ -97,7 +97,7 @@ export class BlockchainBlocksComponent implements OnInit, OnDestroy { this.markBlockSubscription = this.stateService.markBlock$ .subscribe((state) => { this.markHeight = undefined; - if (state.blockHeight) { + if (state.blockHeight !== undefined) { this.markHeight = state.blockHeight; } this.moveArrowToPosition(false); @@ -114,7 +114,7 @@ export class BlockchainBlocksComponent implements OnInit, OnDestroy { } moveArrowToPosition(animate: boolean, newBlockFromLeft = false) { - if (!this.markHeight) { + if (this.markHeight === undefined) { this.arrowVisible = false; return; } From 1f0ae601c59450daeb936dbfcd8928ab6e90d399 Mon Sep 17 00:00:00 2001 From: Antoni Spaanderman <56turtle56@gmail.com> Date: Thu, 20 Jan 2022 17:19:16 +0100 Subject: [PATCH 04/44] add network regtest --- frontend/mempool-frontend-config.sample.json | 1 + frontend/src/app/app-routing.module.ts | 78 +++++++++++++++++++ .../components/amount/amount.component.html | 3 +- .../bisq-master-page.component.html | 3 +- .../app/components/block/block.component.ts | 8 +- .../blockchain-blocks.component.ts | 1 + .../liquid-master-page.component.html | 3 +- .../master-page/master-page.component.html | 3 +- frontend/src/app/services/seo.service.ts | 2 + frontend/src/app/services/state.service.ts | 10 ++- frontend/src/resources/regtest-logo.png | 1 + 11 files changed, 102 insertions(+), 11 deletions(-) create mode 120000 frontend/src/resources/regtest-logo.png diff --git a/frontend/mempool-frontend-config.sample.json b/frontend/mempool-frontend-config.sample.json index 0715cb0bd..b3cbb0b6a 100644 --- a/frontend/mempool-frontend-config.sample.json +++ b/frontend/mempool-frontend-config.sample.json @@ -1,6 +1,7 @@ { "TESTNET_ENABLED": false, "SIGNET_ENABLED": false, + "REGTEST_ENABLED": false, "LIQUID_ENABLED": false, "LIQUID_TESTNET_ENABLED": false, "BISQ_ENABLED": false, diff --git a/frontend/src/app/app-routing.module.ts b/frontend/src/app/app-routing.module.ts index 43705b85e..c72e6d186 100644 --- a/frontend/src/app/app-routing.module.ts +++ b/frontend/src/app/app-routing.module.ts @@ -261,6 +261,84 @@ let routes: Routes = [ }, ] }, + { + path: 'regtest', + children: [ + { + path: '', + component: MasterPageComponent, + children: [ + { + path: 'tx/push', + component: PushTransactionComponent, + }, + { + path: '', + component: StartComponent, + children: [ + { + path: '', + component: DashboardComponent + }, + { + path: 'tx/:id', + component: TransactionComponent + }, + { + path: 'block/:id', + component: BlockComponent + }, + { + path: 'mempool-block/:id', + component: MempoolBlockComponent + }, + ], + }, + { + path: 'blocks', + component: LatestBlocksComponent, + }, + { + path: 'graphs', + component: StatisticsComponent, + }, + { + path: 'address/:id', + children: [], + component: AddressComponent + }, + { + path: 'docs/api/:type', + component: DocsComponent + }, + { + path: 'docs/api', + redirectTo: 'docs/api/rest' + }, + { + path: 'docs', + redirectTo: 'docs/api/rest' + }, + { + path: 'api', + redirectTo: 'docs/api/rest' + }, + ], + }, + { + path: 'tv', + component: TelevisionComponent + }, + { + path: 'status', + component: StatusViewComponent + }, + { + path: '**', + redirectTo: '' + }, + ] + }, { path: 'tv', component: TelevisionComponent, diff --git a/frontend/src/app/components/amount/amount.component.html b/frontend/src/app/components/amount/amount.component.html index 07f669a81..a3e9ea453 100644 --- a/frontend/src/app/components/amount/amount.component.html +++ b/frontend/src/app/components/amount/amount.component.html @@ -10,6 +10,7 @@ L- tL- t - sBTC + s + rBTC diff --git a/frontend/src/app/components/bisq-master-page/bisq-master-page.component.html b/frontend/src/app/components/bisq-master-page/bisq-master-page.component.html index d77f96423..2a2309429 100644 --- a/frontend/src/app/components/bisq-master-page/bisq-master-page.component.html +++ b/frontend/src/app/components/bisq-master-page/bisq-master-page.component.html @@ -10,7 +10,7 @@ -