DROP -> DROP IF EXISTS
This commit is contained in:
		
							parent
							
								
									f982f6b4b6
								
							
						
					
					
						commit
						5b32ab6dde
					
				@ -146,6 +146,10 @@ class Blocks {
 | 
				
			|||||||
   * Index all blocks metadata for the mining dashboard
 | 
					   * Index all blocks metadata for the mining dashboard
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  public async $generateBlockDatabase() {
 | 
					  public async $generateBlockDatabase() {
 | 
				
			||||||
 | 
					    if (['mainnet', 'testnet', 'signet'].includes(config.MEMPOOL.NETWORK) === false) {
 | 
				
			||||||
 | 
					      return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let currentBlockHeight = await bitcoinClient.getBlockCount();
 | 
					    let currentBlockHeight = await bitcoinClient.getBlockCount();
 | 
				
			||||||
    const indexedBlockCount = await blocksRepository.$blockCount();
 | 
					    const indexedBlockCount = await blocksRepository.$blockCount();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -231,7 +235,10 @@ class Blocks {
 | 
				
			|||||||
      const blockExtended: BlockExtended = this.getBlockExtended(block, transactions);
 | 
					      const blockExtended: BlockExtended = this.getBlockExtended(block, transactions);
 | 
				
			||||||
      const miner = await this.$findBlockMiner(blockExtended.coinbaseTx);
 | 
					      const miner = await this.$findBlockMiner(blockExtended.coinbaseTx);
 | 
				
			||||||
      const coinbase: IEsploraApi.Transaction = await bitcoinApi.$getRawTransaction(transactions[0].txid, true);
 | 
					      const coinbase: IEsploraApi.Transaction = await bitcoinApi.$getRawTransaction(transactions[0].txid, true);
 | 
				
			||||||
      await blocksRepository.$saveBlockInDatabase(blockExtended, blockHash, coinbase.hex, miner);
 | 
					
 | 
				
			||||||
 | 
					      if (['mainnet', 'testnet', 'signet'].includes(config.MEMPOOL.NETWORK) === true) {
 | 
				
			||||||
 | 
					        await blocksRepository.$saveBlockInDatabase(blockExtended, blockHash, coinbase.hex, miner);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (block.height % 2016 === 0) {
 | 
					      if (block.height % 2016 === 0) {
 | 
				
			||||||
        this.previousDifficultyRetarget = (block.difficulty - this.currentDifficulty) / this.currentDifficulty * 100;
 | 
					        this.previousDifficultyRetarget = (block.difficulty - this.currentDifficulty) / this.currentDifficulty * 100;
 | 
				
			||||||
 | 
				
			|||||||
@ -87,7 +87,7 @@ class DatabaseMigration {
 | 
				
			|||||||
        await this.$executeQuery(connection, this.getCreatePoolsTableQuery(), await this.$checkIfTableExists('pools'));
 | 
					        await this.$executeQuery(connection, this.getCreatePoolsTableQuery(), await this.$checkIfTableExists('pools'));
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      if (databaseSchemaVersion < 4) {
 | 
					      if (databaseSchemaVersion < 4) {
 | 
				
			||||||
        await this.$executeQuery(connection, 'DROP table blocks;');
 | 
					        await this.$executeQuery(connection, 'DROP table IF EXISTS blocks;');
 | 
				
			||||||
        await this.$executeQuery(connection, this.getCreateBlocksTableQuery(), await this.$checkIfTableExists('blocks'));
 | 
					        await this.$executeQuery(connection, this.getCreateBlocksTableQuery(), await this.$checkIfTableExists('blocks'));
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      connection.release();
 | 
					      connection.release();
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user