Make mining pools url configurable
This commit is contained in:
		
							parent
							
								
									c0e6b7af58
								
							
						
					
					
						commit
						a64cb4bbad
					
				@ -24,6 +24,8 @@ interface IConfig {
 | 
			
		||||
    USER_AGENT: string;
 | 
			
		||||
    STDOUT_LOG_MIN_PRIORITY: 'emerg' | 'alert' | 'crit' | 'err' | 'warn' | 'notice' | 'info' | 'debug';
 | 
			
		||||
    AUTOMATIC_BLOCK_REINDEXING: boolean;
 | 
			
		||||
    POOLS_JSON_URL: string,
 | 
			
		||||
    POOLS_JSON_TREE_URL: string,
 | 
			
		||||
  };
 | 
			
		||||
  ESPLORA: {
 | 
			
		||||
    REST_API_URL: string;
 | 
			
		||||
@ -135,6 +137,8 @@ const defaults: IConfig = {
 | 
			
		||||
    'USER_AGENT': 'mempool',
 | 
			
		||||
    'STDOUT_LOG_MIN_PRIORITY': 'debug',
 | 
			
		||||
    'AUTOMATIC_BLOCK_REINDEXING': false,
 | 
			
		||||
    'POOLS_JSON_URL': 'https://raw.githubusercontent.com/mempool/mining-pools/master/pools.json',
 | 
			
		||||
    'POOLS_JSON_TREE_URL': 'https://api.github.com/repos/mempool/mining-pools/git/trees/master',
 | 
			
		||||
  },
 | 
			
		||||
  'ESPLORA': {
 | 
			
		||||
    'REST_API_URL': 'http://127.0.0.1:3000',
 | 
			
		||||
 | 
			
		||||
@ -12,14 +12,11 @@ import * as https from 'https';
 | 
			
		||||
 */
 | 
			
		||||
class PoolsUpdater {
 | 
			
		||||
  lastRun: number = 0;
 | 
			
		||||
  currentSha: any = undefined;
 | 
			
		||||
  poolsUrl: string = 'https://raw.githubusercontent.com/mempool/mining-pools/master/pools.json';
 | 
			
		||||
  treeUrl: string = 'https://api.github.com/repos/mempool/mining-pools/git/trees/master';
 | 
			
		||||
  currentSha: string | undefined = undefined;
 | 
			
		||||
  poolsUrl: string = config.MEMPOOL.POOLS_JSON_URL;
 | 
			
		||||
  treeUrl: string = config.MEMPOOL.POOLS_JSON_TREE_URL;
 | 
			
		||||
 | 
			
		||||
  constructor() {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public async updatePoolsJson() {
 | 
			
		||||
  public async updatePoolsJson(): Promise<void> {
 | 
			
		||||
    if (['mainnet', 'testnet', 'signet'].includes(config.MEMPOOL.NETWORK) === false) {
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
@ -77,7 +74,7 @@ class PoolsUpdater {
 | 
			
		||||
  /**
 | 
			
		||||
   * Fetch our latest pools.json sha from the db
 | 
			
		||||
   */
 | 
			
		||||
  private async updateDBSha(githubSha: string) {
 | 
			
		||||
  private async updateDBSha(githubSha: string): Promise<void> {
 | 
			
		||||
    this.currentSha = githubSha;
 | 
			
		||||
    if (config.DATABASE.ENABLED === true) {
 | 
			
		||||
      try {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user