Merge pull request #3209 from mempool/nymkappa/wipe-cache-always
Wipe nodejs backend cache for any mining pool change - Update pools before loading disk cache
This commit is contained in:
		
						commit
						fa77161379
					
				@ -39,6 +39,10 @@ class PoolsParser {
 | 
				
			|||||||
   * @param pools 
 | 
					   * @param pools 
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  public async migratePoolsJson(): Promise<void> {
 | 
					  public async migratePoolsJson(): Promise<void> {
 | 
				
			||||||
 | 
					    // We also need to wipe the backend cache to make sure we don't serve blocks with
 | 
				
			||||||
 | 
					    // the wrong mining pool (usually happen with unknown blocks)
 | 
				
			||||||
 | 
					    diskCache.wipeCache();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    await this.$insertUnknownPool();
 | 
					    await this.$insertUnknownPool();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (const pool of this.miningPools) {
 | 
					    for (const pool of this.miningPools) {
 | 
				
			||||||
@ -142,10 +146,6 @@ class PoolsParser {
 | 
				
			|||||||
      WHERE pool_id = ?`,
 | 
					      WHERE pool_id = ?`,
 | 
				
			||||||
      [pool.id]
 | 
					      [pool.id]
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
					 | 
				
			||||||
    // We also need to wipe the backend cache to make sure we don't serve blocks with
 | 
					 | 
				
			||||||
    // the wrong mining pool (usually happen with unknown blocks)
 | 
					 | 
				
			||||||
    diskCache.wipeCache();
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private async $deleteUnknownBlocks(): Promise<void> {
 | 
					  private async $deleteUnknownBlocks(): Promise<void> {
 | 
				
			||||||
@ -156,10 +156,6 @@ class PoolsParser {
 | 
				
			|||||||
      WHERE pool_id = ? AND height >= 130635`,
 | 
					      WHERE pool_id = ? AND height >= 130635`,
 | 
				
			||||||
      [unknownPool[0].id]
 | 
					      [unknownPool[0].id]
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
					 | 
				
			||||||
    // We also need to wipe the backend cache to make sure we don't serve blocks with
 | 
					 | 
				
			||||||
    // the wrong mining pool (usually happen with unknown blocks)
 | 
					 | 
				
			||||||
    diskCache.wipeCache();
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -113,6 +113,7 @@ class Server {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    this.setUpWebsocketHandling();
 | 
					    this.setUpWebsocketHandling();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    await poolsUpdater.updatePoolsJson(); // Needs to be done before loading the disk cache because we sometimes wipe it
 | 
				
			||||||
    await syncAssets.syncAssets$();
 | 
					    await syncAssets.syncAssets$();
 | 
				
			||||||
    if (config.MEMPOOL.ENABLED) {
 | 
					    if (config.MEMPOOL.ENABLED) {
 | 
				
			||||||
      diskCache.loadMempoolCache();
 | 
					      diskCache.loadMempoolCache();
 | 
				
			||||||
@ -171,7 +172,6 @@ class Server {
 | 
				
			|||||||
          logger.debug(msg);
 | 
					          logger.debug(msg);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      await poolsUpdater.updatePoolsJson();
 | 
					 | 
				
			||||||
      await blocks.$updateBlocks();
 | 
					      await blocks.$updateBlocks();
 | 
				
			||||||
      await memPool.$updateMempool();
 | 
					      await memPool.$updateMempool();
 | 
				
			||||||
      indexer.$run();
 | 
					      indexer.$run();
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user