Fixed cn_props ETL, lightning startup and more

This commit is contained in:
kexkey
2021-11-24 00:26:45 -05:00
parent 4251a0c153
commit 8f1798dffc
6 changed files with 29 additions and 17 deletions

View File

@@ -43,7 +43,7 @@ CREATE TABLE tx (
fee REAL,
size INTEGER,
vsize INTEGER,
is_replaceable BOOLEAN,
is_replaceable BOOLEAN,
blockhash VARCHAR,
blockheight INTEGER,
blocktime BIGINT,

View File

@@ -22,17 +22,17 @@ if [ "$?" -eq "1" ]; then
date
echo "...appending postgresql sequences..."
echo "
select setval('cyphernode_props_id_seq', (SELECT MAX(id) FROM cyphernode_props));
select setval('ln_invoice_id_seq', (SELECT MAX(id) FROM ln_invoice));
select setval('recipient_id_seq', (SELECT MAX(id) FROM recipient));
select setval('stamp_id_seq', (SELECT MAX(id) FROM stamp));
select setval('tx_id_seq', (SELECT MAX(id) FROM tx));
select setval('watching_by_pub32_id_seq', (SELECT MAX(id) FROM watching_by_pub32));
select setval('watching_by_txid_id_seq', (SELECT MAX(id) FROM watching_by_txid));
select setval('watching_id_seq', (SELECT MAX(id) FROM watching));
select setval('batcher_id_seq', (SELECT MAX(id) FROM batcher));
commit;
" >> ${DB_PATH}/sqlmigrate20211105_0.7.0-0.8.0_sqlite3-extracted-data.sql
select setval('cyphernode_props_id_seq', (SELECT MAX(id) FROM cyphernode_props));
select setval('ln_invoice_id_seq', (SELECT MAX(id) FROM ln_invoice));
select setval('recipient_id_seq', (SELECT MAX(id) FROM recipient));
select setval('stamp_id_seq', (SELECT MAX(id) FROM stamp));
select setval('tx_id_seq', (SELECT MAX(id) FROM tx));
select setval('watching_by_pub32_id_seq', (SELECT MAX(id) FROM watching_by_pub32));
select setval('watching_by_txid_id_seq', (SELECT MAX(id) FROM watching_by_txid));
select setval('watching_id_seq', (SELECT MAX(id) FROM watching));
select setval('batcher_id_seq', (SELECT MAX(id) FROM batcher));
commit;
" >> ${DB_PATH}/sqlmigrate20211105_0.7.0-0.8.0_sqlite3-extracted-data.sql
date
echo "Importing sqlite3 data into postgresql..."

View File

@@ -17,8 +17,11 @@ select id,address,amount,tx_id,inserted_ts,webhook_url,case when calledback=1 th
select id,txid,case when watching=1 then 'TRUE' else 'FALSE' end as watching,callback1conf,case when calledback1conf=1 then 'TRUE' else 'FALSE' end as calledback1conf,callbackxconf,case when calledbackxconf=1 then 'TRUE' else 'FALSE' end as calledbackxconf,nbxconf,inserted_ts from watching_by_txid;
.mode insert stamp
select id,hash,callbackUrl,case when requested=1 then 'TRUE' else 'FALSE' end as requested,case when upgraded=1 then 'TRUE' else 'FALSE' end as upgraded,case when calledback=1 then 'TRUE' else 'FALSE' end as calledback,inserted_ts from stamp;
.mode insert cyphernode_props
select * from cyphernode_props;
-- cyphernode_props rows were already inserted in db creation, let's update them here
.headers off
.mode list cyphernode_props
select 'update cyphernode_props set value=''' || value || ''', inserted_ts=''' || inserted_ts || ''' where id=' || id || ';' from cyphernode_props;
.headers on
.mode insert ln_invoice
select id,label,bolt11,payment_hash,msatoshi,status,pay_index,msatoshi_received,paid_at,description,expires_at,callback_url,case when calledback=1 then 'TRUE' else 'FALSE' end as calledback,case when callback_failed=1 then 'TRUE' else 'FALSE' end as callback_failed,inserted_ts from ln_invoice;
.quit

View File

@@ -9,7 +9,7 @@ createbatcher() {
# POST http://192.168.111.152:8080/createbatcher
#
# Will UPDATE the batcher is it already exists (as per label)
# Will UPDATE the batcher if it already exists (as per label)
#
# args:
# - batcherLabel, optional, id can be used to reference the batcher

View File

@@ -51,6 +51,8 @@ ln_waitanyinvoice() {
sql "UPDATE cyphernode_props SET value='${pay_index}' WHERE property='pay_index'"
fi
return ${returncode}
}
while :
@@ -58,5 +60,12 @@ do
pay_index=$(sql "SELECT value FROM cyphernode_props WHERE property='pay_index'")
trace "[waitanyinvoice] pay_index=${pay_index}"
ln_waitanyinvoice ${pay_index}
sleep 5
if [ "$?" -eq "0" ]; then
# lightning is ready, let's wait 1 sec to fetch next pay_index...
sleep 1
else
# lightning is not ready, let's wait a little more...
sleep 5
fi
done