mirror of
https://github.com/mempool/mempool.git
synced 2025-03-03 17:47:01 +01:00
If pool slug does not exist, generate one on the fly, avoid crash
This commit is contained in:
parent
8114ffe1c8
commit
810c335759
1 changed files with 18 additions and 1 deletions
|
@ -12,6 +12,8 @@ interface Pool {
|
||||||
}
|
}
|
||||||
|
|
||||||
class PoolsParser {
|
class PoolsParser {
|
||||||
|
slugWarnFlag = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse the pools.json file, consolidate the data and dump it into the database
|
* Parse the pools.json file, consolidate the data and dump it into the database
|
||||||
*/
|
*/
|
||||||
|
@ -93,7 +95,22 @@ class PoolsParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
const finalPoolName = poolNames[i].replace(`'`, `''`); // To support single quote in names when doing db queries
|
const finalPoolName = poolNames[i].replace(`'`, `''`); // To support single quote in names when doing db queries
|
||||||
const slug = poolsJson['slugs'][poolNames[i]];
|
|
||||||
|
let slug: string | undefined;
|
||||||
|
try {
|
||||||
|
slug = poolsJson['slugs'][poolNames[i]];
|
||||||
|
} catch (e) {
|
||||||
|
if (this.slugWarnFlag === false) {
|
||||||
|
logger.warn(`pools.json does not seem to contain the 'slugs' object`);
|
||||||
|
this.slugWarnFlag = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (slug === undefined) {
|
||||||
|
// Only keep alphanumerical
|
||||||
|
slug = poolNames[i].replace(/[^a-z0-9]/gi,'').toLowerCase();
|
||||||
|
logger.debug(`No slug found for '${poolNames[i]}', generating it => '${slug}'`);
|
||||||
|
}
|
||||||
|
|
||||||
if (existingPools.find((pool) => pool.name === poolNames[i]) !== undefined) {
|
if (existingPools.find((pool) => pool.name === poolNames[i]) !== undefined) {
|
||||||
finalPoolDataUpdate.push({
|
finalPoolDataUpdate.push({
|
||||||
|
|
Loading…
Add table
Reference in a new issue