diff --git a/.github/workflows/on-tag.yml b/.github/workflows/on-tag.yml index a1093a261..32d4b085b 100644 --- a/.github/workflows/on-tag.yml +++ b/.github/workflows/on-tag.yml @@ -68,24 +68,24 @@ jobs: run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin - name: Checkout project - uses: actions/checkout@629c2de402a417ea7690ca6ce3f33229e27606a5 # v2 + uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 # v2.5.0 - name: Init repo for Dockerization run: docker/init.sh "$TAG" - name: Set up QEMU - uses: docker/setup-qemu-action@27d0a4f181a40b142cce983c5393082c365d1480 # v1 + uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 # v2.1.0 id: qemu - name: Setup Docker buildx action - uses: docker/setup-buildx-action@94ab11c41e45d028884a99163086648e898eed25 # v1 + uses: docker/setup-buildx-action@8c0edbc76e98fa90f69d9a2c020dcb50019dc325 # v2.2.1 id: buildx - name: Available platforms run: echo ${{ steps.buildx.outputs.platforms }} - name: Cache Docker layers - uses: actions/cache@661fd3eb7f2f20d8c7c84bc2b0509efd7a826628 # v2 + uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11 id: cache with: path: /tmp/.buildx-cache diff --git a/backend/src/api/pools-parser.ts b/backend/src/api/pools-parser.ts index 731653a83..ae6bd52ce 100644 --- a/backend/src/api/pools-parser.ts +++ b/backend/src/api/pools-parser.ts @@ -14,10 +14,10 @@ interface Pool { class PoolsParser { miningPools: any[] = []; unknownPool: any = { - 'name': "Unknown", - 'link': "https://learnmeabitcoin.com/technical/coinbase-transaction", - 'regexes': "[]", - 'addresses': "[]", + 'name': 'Unknown', + 'link': 'https://learnmeabitcoin.com/technical/coinbase-transaction', + 'regexes': '[]', + 'addresses': '[]', 'slug': 'unknown' }; slugWarnFlag = false; @@ -25,7 +25,7 @@ class PoolsParser { /** * Parse the pools.json file, consolidate the data and dump it into the database */ - public async migratePoolsJson(poolsJson: object) { + public async migratePoolsJson(poolsJson: object): Promise { if (['mainnet', 'testnet', 'signet'].includes(config.MEMPOOL.NETWORK) === false) { return; } @@ -81,6 +81,7 @@ class PoolsParser { // Finally, we generate the final consolidated pools data const finalPoolDataAdd: Pool[] = []; const finalPoolDataUpdate: Pool[] = []; + const finalPoolDataRename: Pool[] = []; for (let i = 0; i < poolNames.length; ++i) { let allAddresses: string[] = []; let allRegexes: string[] = []; @@ -127,8 +128,26 @@ class PoolsParser { finalPoolDataUpdate.push(poolObj); } } else { - logger.debug(`Add '${finalPoolName}' mining pool`); - finalPoolDataAdd.push(poolObj); + // Double check that if we're not just renaming a pool (same address same regex) + const [poolToRename]: any[] = await DB.query(` + SELECT * FROM pools + WHERE addresses = ? OR regexes = ?`, + [JSON.stringify(poolObj.addresses), JSON.stringify(poolObj.regexes)] + ); + if (poolToRename && poolToRename.length > 0) { + // We're actually renaming an existing pool + finalPoolDataRename.push({ + 'name': poolObj.name, + 'link': poolObj.link, + 'regexes': allRegexes, + 'addresses': allAddresses, + 'slug': slug + }); + logger.debug(`Rename '${poolToRename[0].name}' mining pool to ${poolObj.name}`); + } else { + logger.debug(`Add '${finalPoolName}' mining pool`); + finalPoolDataAdd.push(poolObj); + } } this.miningPools.push({ @@ -145,7 +164,9 @@ class PoolsParser { return; } - if (finalPoolDataAdd.length > 0 || finalPoolDataUpdate.length > 0) { + if (finalPoolDataAdd.length > 0 || finalPoolDataUpdate.length > 0 || + finalPoolDataRename.length > 0 + ) { logger.debug(`Update pools table now`); // Add new mining pools into the database @@ -169,8 +190,22 @@ class PoolsParser { ;`); } + // Rename mining pools + const renameQueries: string[] = []; + for (let i = 0; i < finalPoolDataRename.length; ++i) { + renameQueries.push(` + UPDATE pools + SET name='${finalPoolDataRename[i].name}', link='${finalPoolDataRename[i].link}', + slug='${finalPoolDataRename[i].slug}' + WHERE regexes='${JSON.stringify(finalPoolDataRename[i].regexes)}' + AND addresses='${JSON.stringify(finalPoolDataRename[i].addresses)}' + ;`); + } + try { - await this.$deleteBlocskToReindex(finalPoolDataUpdate); + if (finalPoolDataAdd.length > 0 || updateQueries.length > 0) { + await this.$deleteBlocskToReindex(finalPoolDataUpdate); + } if (finalPoolDataAdd.length > 0) { await DB.query({ sql: queryAdd, timeout: 120000 }); @@ -178,6 +213,9 @@ class PoolsParser { for (const query of updateQueries) { await DB.query({ sql: query, timeout: 120000 }); } + for (const query of renameQueries) { + await DB.query({ sql: query, timeout: 120000 }); + } await this.insertUnknownPool(); logger.info('Mining pools.json import completed'); } catch (e) { diff --git a/frontend/src/app/app.constants.ts b/frontend/src/app/app.constants.ts index 232578e6b..9cd374cd0 100644 --- a/frontend/src/app/app.constants.ts +++ b/frontend/src/app/app.constants.ts @@ -79,7 +79,7 @@ export const poolsColor = { 'binancepool': '#1E88E5', 'viabtc': '#039BE5', 'btccom': '#00897B', - 'slushpool': '#00ACC1', + 'braiinspool': '#00ACC1', 'sbicrypto': '#43A047', 'marapool': '#7CB342', 'luxor': '#C0CA33', diff --git a/frontend/src/app/components/block-overview-graph/block-overview-graph.component.ts b/frontend/src/app/components/block-overview-graph/block-overview-graph.component.ts index 751781d19..7bb4378a6 100644 --- a/frontend/src/app/components/block-overview-graph/block-overview-graph.component.ts +++ b/frontend/src/app/components/block-overview-graph/block-overview-graph.component.ts @@ -188,7 +188,7 @@ export class BlockOverviewGraphComponent implements AfterViewInit, OnDestroy, On this.gl.viewport(0, 0, this.displayWidth, this.displayHeight); } if (this.scene) { - this.scene.resize({ width: this.displayWidth, height: this.displayHeight }); + this.scene.resize({ width: this.displayWidth, height: this.displayHeight, animate: false }); this.start(); } else { this.scene = new BlockScene({ width: this.displayWidth, height: this.displayHeight, resolution: this.resolution, diff --git a/frontend/src/app/components/block-overview-graph/block-scene.ts b/frontend/src/app/components/block-overview-graph/block-scene.ts index 39ac44e7a..8d3c46af4 100644 --- a/frontend/src/app/components/block-overview-graph/block-scene.ts +++ b/frontend/src/app/components/block-overview-graph/block-scene.ts @@ -29,7 +29,7 @@ export default class BlockScene { this.init({ width, height, resolution, blockLimit, orientation, flip, vertexArray }); } - resize({ width = this.width, height = this.height }: { width?: number, height?: number}): void { + resize({ width = this.width, height = this.height, animate = true }: { width?: number, height?: number, animate: boolean }): void { this.width = width; this.height = height; this.gridSize = this.width / this.gridWidth; @@ -38,7 +38,7 @@ export default class BlockScene { this.dirty = true; if (this.initialised && this.scene) { - this.updateAll(performance.now(), 50); + this.updateAll(performance.now(), 50, 'left', animate); } } @@ -212,7 +212,7 @@ export default class BlockScene { this.vbytesPerUnit = blockLimit / Math.pow(resolution / 1.02, 2); this.gridWidth = resolution; this.gridHeight = resolution; - this.resize({ width, height }); + this.resize({ width, height, animate: true }); this.layout = new BlockLayout({ width: this.gridWidth, height: this.gridHeight }); this.txs = {}; @@ -225,14 +225,14 @@ export default class BlockScene { this.animateUntil = Math.max(this.animateUntil, tx.update(update)); } - private updateTx(tx: TxView, startTime: number, delay: number, direction: string = 'left'): void { + private updateTx(tx: TxView, startTime: number, delay: number, direction: string = 'left', animate: boolean = true): void { if (tx.dirty || this.dirty) { this.saveGridToScreenPosition(tx); - this.setTxOnScreen(tx, startTime, delay, direction); + this.setTxOnScreen(tx, startTime, delay, direction, animate); } } - private setTxOnScreen(tx: TxView, startTime: number, delay: number = 50, direction: string = 'left'): void { + private setTxOnScreen(tx: TxView, startTime: number, delay: number = 50, direction: string = 'left', animate: boolean = true): void { if (!tx.initialised) { const txColor = tx.getColor(); this.applyTxUpdate(tx, { @@ -252,30 +252,42 @@ export default class BlockScene { position: tx.screenPosition, color: txColor }, - duration: 1000, + duration: animate ? 1000 : 1, start: startTime, - delay, + delay: animate ? delay : 0, }); } else { this.applyTxUpdate(tx, { display: { position: tx.screenPosition }, - duration: 1000, - minDuration: 500, + duration: animate ? 1000 : 0, + minDuration: animate ? 500 : 0, start: startTime, - delay, - adjust: true + delay: animate ? delay : 0, + adjust: animate }); + if (!animate) { + this.applyTxUpdate(tx, { + display: { + position: tx.screenPosition + }, + duration: 0, + minDuration: 0, + start: startTime, + delay: 0, + adjust: false + }); + } } } - private updateAll(startTime: number, delay: number = 50, direction: string = 'left'): void { + private updateAll(startTime: number, delay: number = 50, direction: string = 'left', animate: boolean = true): void { this.scene.count = 0; const ids = this.getTxList(); startTime = startTime || performance.now(); for (const id of ids) { - this.updateTx(this.txs[id], startTime, delay, direction); + this.updateTx(this.txs[id], startTime, delay, direction, animate); } this.dirty = false; } diff --git a/frontend/src/app/components/transaction/transaction-preview.component.ts b/frontend/src/app/components/transaction/transaction-preview.component.ts index cc9dfac56..6c04af0ab 100644 --- a/frontend/src/app/components/transaction/transaction-preview.component.ts +++ b/frontend/src/app/components/transaction/transaction-preview.component.ts @@ -117,8 +117,9 @@ export class TransactionPreviewComponent implements OnInit, OnDestroy { }), switchMap(() => { let transactionObservable$: Observable; - if (history.state.data && history.state.data.fee !== -1) { - transactionObservable$ = of(history.state.data); + const cached = this.stateService.getTxFromCache(this.txId); + if (cached && cached.fee !== -1) { + transactionObservable$ = of(cached); } else { transactionObservable$ = this.electrsApiService .getTransaction$(this.txId) diff --git a/frontend/src/app/components/transaction/transaction.component.html b/frontend/src/app/components/transaction/transaction.component.html index 2f4fb7ba2..cd0cd716d 100644 --- a/frontend/src/app/components/transaction/transaction.component.html +++ b/frontend/src/app/components/transaction/transaction.component.html @@ -3,7 +3,7 @@