mirror of
https://github.com/alexgo-io/OPI.git
synced 2026-01-12 16:53:13 +08:00
added eslint to js modules, fixed found errors
This commit is contained in:
@@ -5,7 +5,7 @@ DB_PORT="5432"
|
||||
DB_DATABASE="postgres_bitmap"
|
||||
DB_PASSWD=""
|
||||
DB_SSL="true"
|
||||
DB_MAX_CONNECTIONS=200
|
||||
DB_MAX_CONNECTIONS=10
|
||||
|
||||
API_HOST="127.0.0.1"
|
||||
API_PORT="8001"
|
||||
|
||||
13
modules/bitmap_api/.eslintrc.json
Normal file
13
modules/bitmap_api/.eslintrc.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"env": {
|
||||
"commonjs": true,
|
||||
"es2021": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": "latest"
|
||||
},
|
||||
"rules": {
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ var db_pool = new Pool({
|
||||
database: process.env.DB_DATABASE || 'postgres',
|
||||
password: process.env.DB_PASSWD,
|
||||
port: parseInt(process.env.DB_PORT || "5432"),
|
||||
max: process.env.DB_MAX_CONNECTIONS || 100, // maximum number of clients!!
|
||||
max: process.env.DB_MAX_CONNECTIONS || 10, // maximum number of clients!!
|
||||
ssl: process.env.DB_SSL == 'true' ? true : false
|
||||
})
|
||||
const api_port = parseInt(process.env.API_PORT || "8001")
|
||||
@@ -40,7 +40,7 @@ async function get_block_height_of_db() {
|
||||
app.get('/v1/bitmap/block_height', (request, response) => response.send(get_block_height_of_db()))
|
||||
|
||||
app.get('/v1/bitmap/get_hash_of_all_activity', async (request, response) => {
|
||||
let block_height = params.block_height
|
||||
let block_height = request.params.block_height
|
||||
|
||||
let current_block_height = await get_block_height_of_db()
|
||||
if (block_height > current_block_height) {
|
||||
|
||||
3436
modules/bitmap_api/package-lock.json
generated
Normal file
3436
modules/bitmap_api/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -5,9 +5,12 @@
|
||||
"license": "UNLICENSED",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"pg": "^8.6.0",
|
||||
"dotenv": "16.3.1",
|
||||
"cors": "^2.8.5",
|
||||
"express": "4.18.2"
|
||||
"dotenv": "16.3.1",
|
||||
"express": "4.18.2",
|
||||
"pg": "^8.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^8.55.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ DB_PORT="5432"
|
||||
DB_DATABASE="postgres_brc20"
|
||||
DB_PASSWD=""
|
||||
DB_SSL="true"
|
||||
DB_MAX_CONNECTIONS=200
|
||||
DB_MAX_CONNECTIONS=10
|
||||
|
||||
API_HOST="127.0.0.1"
|
||||
API_PORT="8000"
|
||||
|
||||
13
modules/brc20_api/.eslintrc.json
Normal file
13
modules/brc20_api/.eslintrc.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"env": {
|
||||
"commonjs": true,
|
||||
"es2021": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": "latest"
|
||||
},
|
||||
"rules": {
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ var db_pool = new Pool({
|
||||
database: process.env.DB_DATABASE || 'postgres',
|
||||
password: process.env.DB_PASSWD,
|
||||
port: parseInt(process.env.DB_PORT || "5432"),
|
||||
max: process.env.DB_MAX_CONNECTIONS || 100, // maximum number of clients!!
|
||||
max: process.env.DB_MAX_CONNECTIONS || 10, // maximum number of clients!!
|
||||
ssl: process.env.DB_SSL == 'true' ? true : false
|
||||
})
|
||||
const api_port = parseInt(process.env.API_PORT || "8000")
|
||||
@@ -41,9 +41,9 @@ app.get('/v1/brc20/block_height', (request, response) => response.send(get_block
|
||||
|
||||
// get a given ticker balance of a given pkscript at the start of a given block height
|
||||
app.get('/v1/brc20/balance_on_block', async (request, response) => {
|
||||
let block_height = params.block_height
|
||||
let pkscript = params.pkscript
|
||||
let tick = params.ticker.toLowerCase()
|
||||
let block_height = request.params.block_height
|
||||
let pkscript = request.params.pkscript
|
||||
let tick = request.params.ticker.toLowerCase()
|
||||
|
||||
let current_block_height = await get_block_height_of_db()
|
||||
if (block_height > current_block_height + 1) {
|
||||
@@ -68,7 +68,7 @@ app.get('/v1/brc20/balance_on_block', async (request, response) => {
|
||||
|
||||
// get all brc20 activity of a given block height
|
||||
app.get('/v1/brc20/activity_on_block', async (request, response) => {
|
||||
let block_height = params.block_height
|
||||
let block_height = request.params.block_height
|
||||
|
||||
let current_block_height = await get_block_height_of_db()
|
||||
if (block_height > current_block_height) {
|
||||
@@ -94,7 +94,7 @@ app.get('/v1/brc20/activity_on_block', async (request, response) => {
|
||||
let inscription_id = row.inscription_id
|
||||
event.event_type = event_type
|
||||
event.inscription_id = inscription_id
|
||||
result.push(event_obj)
|
||||
result.push(event)
|
||||
}
|
||||
response.send({ error: null, result: result })
|
||||
});
|
||||
@@ -129,7 +129,7 @@ app.get('/v1/brc20/get_current_balance_of_wallet', async (request, response) =>
|
||||
});
|
||||
|
||||
app.get('/v1/brc20/get_hash_of_all_activity', async (request, response) => {
|
||||
let block_height = params.block_height
|
||||
let block_height = request.params.block_height
|
||||
|
||||
let current_block_height = await get_block_height_of_db()
|
||||
if (block_height > current_block_height) {
|
||||
|
||||
3436
modules/brc20_api/package-lock.json
generated
Normal file
3436
modules/brc20_api/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -9,5 +9,8 @@
|
||||
"dotenv": "16.3.1",
|
||||
"cors": "^2.8.5",
|
||||
"express": "4.18.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^8.55.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ DB_PORT="5432"
|
||||
DB_DATABASE="postgres_metaprotocol"
|
||||
DB_PASSWD=""
|
||||
DB_SSL="true"
|
||||
DB_MAX_CONNECTIONS=200
|
||||
DB_MAX_CONNECTIONS=50
|
||||
|
||||
BITCOIN_CHAIN_FOLDER="~/.bitcoin/"
|
||||
ORD_BINARY="ord"
|
||||
|
||||
13
modules/main_index/.eslintrc.json
Normal file
13
modules/main_index/.eslintrc.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"env": {
|
||||
"commonjs": true,
|
||||
"es2021": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": "latest"
|
||||
},
|
||||
"rules": {
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ var db_pool = new Pool({
|
||||
database: process.env.DB_DATABASE || 'postgres',
|
||||
password: process.env.DB_PASSWD,
|
||||
port: parseInt(process.env.DB_PORT || "5432"),
|
||||
max: process.env.DB_MAX_CONNECTIONS || 200, // maximum number of clients!!
|
||||
max: process.env.DB_MAX_CONNECTIONS || 50, // maximum number of clients!!
|
||||
ssl: process.env.DB_SSL == 'true' ? true : false
|
||||
})
|
||||
|
||||
@@ -50,6 +50,7 @@ async function main_index() {
|
||||
await check_db()
|
||||
|
||||
let first = true;
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
while (true) {
|
||||
if (first) first = false
|
||||
else await delay(2)
|
||||
@@ -201,7 +202,7 @@ async function main_index() {
|
||||
}
|
||||
if (!next_expected_start) {
|
||||
console.error("logs didn't end with block_end - did ord crash?")
|
||||
all_tm = +(new Date()) - start_tm
|
||||
let all_tm = +(new Date()) - start_tm
|
||||
ord_index_tm = Math.round(ord_index_tm)
|
||||
all_tm = Math.round(all_tm)
|
||||
|
||||
@@ -350,7 +351,7 @@ async function main_index() {
|
||||
ord_sql_tm = Math.round(ord_sql_tm)
|
||||
update_log_tm = Math.round(update_log_tm)
|
||||
|
||||
all_tm = +(new Date()) - start_tm
|
||||
let all_tm = +(new Date()) - start_tm
|
||||
all_tm = Math.round(all_tm)
|
||||
|
||||
await db_pool.query(`INSERT into ord_indexer_work_stats
|
||||
@@ -388,23 +389,23 @@ function wallet_from_pkscript(pkscript) {
|
||||
try {
|
||||
let address = bitcoin.payments.p2tr({ output: Buffer.from(pkscript, 'hex') })
|
||||
return address.address
|
||||
} catch {}
|
||||
} catch { /* try others */ }
|
||||
try {
|
||||
let address = bitcoin.payments.p2wsh({ output: Buffer.from(pkscript, 'hex') })
|
||||
return address.address
|
||||
} catch {}
|
||||
} catch { /* try others */ }
|
||||
try {
|
||||
let address = bitcoin.payments.p2wpkh({ output: Buffer.from(pkscript, 'hex') })
|
||||
return address.address
|
||||
} catch {}
|
||||
} catch { /* try others */ }
|
||||
try {
|
||||
let address = bitcoin.payments.p2sh({ output: Buffer.from(pkscript, 'hex') })
|
||||
return address.address
|
||||
} catch {}
|
||||
} catch { /* try others */ }
|
||||
try {
|
||||
let address = bitcoin.payments.p2pkh({ output: Buffer.from(pkscript, 'hex') })
|
||||
return address.address
|
||||
} catch {}
|
||||
} catch { /* end */ }
|
||||
|
||||
return null
|
||||
}
|
||||
@@ -417,10 +418,10 @@ async function handle_reorg(block_height) {
|
||||
await db_pool.query(`DELETE from ord_content where block_height > $1;`, [last_correct_blockheight])
|
||||
await db_pool.query(`DELETE from block_hashes where block_height > $1;`, [last_correct_blockheight])
|
||||
|
||||
await db_client.query(`SELECT setval('ord_transfers_id_seq', max(id)) from ord_transfers;`)
|
||||
await db_client.query(`SELECT setval('ord_number_to_id_id_seq', max(id)) from ord_number_to_id;`)
|
||||
await db_client.query(`SELECT setval('ord_content_id_seq', max(id)) from ord_content;`)
|
||||
await db_client.query(`SELECT setval('block_hashes_id_seq', max(id)) from block_hashes;`)
|
||||
await db_pool.query(`SELECT setval('ord_transfers_id_seq', max(id)) from ord_transfers;`)
|
||||
await db_pool.query(`SELECT setval('ord_number_to_id_id_seq', max(id)) from ord_number_to_id;`)
|
||||
await db_pool.query(`SELECT setval('ord_content_id_seq', max(id)) from ord_content;`)
|
||||
await db_pool.query(`SELECT setval('block_hashes_id_seq', max(id)) from block_hashes;`)
|
||||
}
|
||||
|
||||
async function check_db() {
|
||||
|
||||
2424
modules/main_index/package-lock.json
generated
Normal file
2424
modules/main_index/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -6,9 +6,12 @@
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"bitcoinjs-lib": "^6.1.0",
|
||||
"dotenv": "16.3.1",
|
||||
"fs": "0.0.1-security",
|
||||
"pg": "^8.6.0",
|
||||
"dotenv": "16.3.1",
|
||||
"tiny-secp256k1": "^2.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^8.55.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user