mirror of
https://github.com/mempool/mempool.git
synced 2025-01-18 05:12:35 +01:00
Fix xxxWindowPreference management
This commit is contained in:
parent
4b9bfd6ca0
commit
b8410f00d9
@ -2,32 +2,21 @@
|
|||||||
|
|
||||||
The backend is static. Typescript scripts are compiled into the `dist` folder and served through a node web server.
|
The backend is static. Typescript scripts are compiled into the `dist` folder and served through a node web server.
|
||||||
|
|
||||||
You can avoid the manual shutdown/recompile/restart command line cycle by setting up watchers.
|
You can avoid the manual shutdown/recompile/restart command line cycle by using a watcher.
|
||||||
|
|
||||||
Make sure you are in the `backend` directory `cd backend`.
|
Make sure you are in the `backend` directory `cd backend`.
|
||||||
|
|
||||||
1. Install nodemon
|
1. Install nodemon and ts-node
|
||||||
|
|
||||||
```
|
```
|
||||||
sudo npm install -g nodemon
|
sudo npm install -g ts-node nodemon
|
||||||
```
|
```
|
||||||
2. [Optional] Add the following configuration into `tsconfig.json`. You can find watch options here https://www.typescriptlang.org/docs/handbook/configuring-watch.html
|
|
||||||
```
|
2. Run the watcher
|
||||||
"watchOptions": {
|
|
||||||
"watchFile": "useFsEvents",
|
> Note: You can find your npm global binary folder using `npm -g bin`, where nodemon will be installed.
|
||||||
"watchDirectory": "useFsEvents",
|
|
||||||
"fallbackPolling": "dynamicPriority",
|
```
|
||||||
"synchronousWatchDirectory": true,
|
nodemon src/index.ts --ignore cache/
|
||||||
"excludeDirectories": ["**/node_modules", "_build"],
|
|
||||||
"excludeFiles": ["build/fileWhichChangesOften.ts"]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
3. In one terminal, watch typescript scripts
|
|
||||||
```
|
|
||||||
./node_modules/typescript/bin/tsc --watch
|
|
||||||
```
|
|
||||||
4. In another terminal, watch compiled javascript
|
|
||||||
```
|
|
||||||
nodemon --max-old-space-size=2048 dist/index.js
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Everytime you save a backend `.ts` file, `tsc` will recompile it and genereate a new static `.js` file in the `dist` folder. `nodemon` will detect this new file and restart the node web server automatically.
|
|
||||||
|
@ -38,29 +38,12 @@ class BlocksRepository {
|
|||||||
|
|
||||||
await connection.query(query, params);
|
await connection.query(query, params);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
|
||||||
logger.err('$updateBlocksDatabase() error' + (e instanceof Error ? e.message : e));
|
logger.err('$updateBlocksDatabase() error' + (e instanceof Error ? e.message : e));
|
||||||
}
|
}
|
||||||
|
|
||||||
connection.release();
|
connection.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a block has already been indexed in the database. Query the databse directly.
|
|
||||||
* This can be cached/optimized if required later on to avoid too many db queries.
|
|
||||||
*/
|
|
||||||
public async $isBlockAlreadyIndexed(blockHeight: number) {
|
|
||||||
const connection = await DB.pool.getConnection();
|
|
||||||
let exists = false;
|
|
||||||
|
|
||||||
const query = `SELECT height from blocks where blocks.height = ${blockHeight}`;
|
|
||||||
const [rows]: any[] = await connection.query(query);
|
|
||||||
exists = rows.length === 1;
|
|
||||||
connection.release();
|
|
||||||
|
|
||||||
return exists;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all block height that have not been indexed between [startHeight, endHeight]
|
* Get all block height that have not been indexed between [startHeight, endHeight]
|
||||||
*/
|
*/
|
||||||
|
@ -78,6 +78,7 @@ export class PoolRankingComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onChangeWindowPreference(e) {
|
onChangeWindowPreference(e) {
|
||||||
|
this.storageService.setValue('poolsWindowPreference', e.target.value);
|
||||||
this.poolsWindowPreference = e.target.value;
|
this.poolsWindowPreference = e.target.value;
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
this.refreshMiningStats();
|
this.refreshMiningStats();
|
||||||
|
@ -13,12 +13,17 @@ export class StorageService {
|
|||||||
setDefaultValueIfNeeded(key: string, defaultValue: string) {
|
setDefaultValueIfNeeded(key: string, defaultValue: string) {
|
||||||
let graphWindowPreference: string = this.getValue(key);
|
let graphWindowPreference: string = this.getValue(key);
|
||||||
if (graphWindowPreference === null) { // First visit to mempool.space
|
if (graphWindowPreference === null) { // First visit to mempool.space
|
||||||
if (this.router.url.includes("graphs") || this.router.url.includes("pools")) {
|
if (this.router.url.includes('graphs') && key === 'graphWindowPreference' ||
|
||||||
|
this.router.url.includes('pools') && key === 'poolsWindowPreference'
|
||||||
|
) {
|
||||||
this.setValue(key, this.route.snapshot.fragment ? this.route.snapshot.fragment : defaultValue);
|
this.setValue(key, this.route.snapshot.fragment ? this.route.snapshot.fragment : defaultValue);
|
||||||
} else {
|
} else {
|
||||||
this.setValue(key, defaultValue);
|
this.setValue(key, defaultValue);
|
||||||
}
|
}
|
||||||
} else if (this.router.url.includes("graphs") || this.router.url.includes("pools")) { // Visit a different graphs#fragment from last visit
|
} else if (this.router.url.includes('graphs') && key === 'graphWindowPreference' ||
|
||||||
|
this.router.url.includes('pools') && key === 'poolsWindowPreference'
|
||||||
|
) {
|
||||||
|
// Visit a different graphs#fragment from last visit
|
||||||
if (this.route.snapshot.fragment !== null && graphWindowPreference !== this.route.snapshot.fragment) {
|
if (this.route.snapshot.fragment !== null && graphWindowPreference !== this.route.snapshot.fragment) {
|
||||||
this.setValue(key, this.route.snapshot.fragment);
|
this.setValue(key, this.route.snapshot.fragment);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user