From 8f1798dffc74f8f89318bffd4cb01a0df78f3146 Mon Sep 17 00:00:00 2001 From: kexkey Date: Wed, 24 Nov 2021 00:26:45 -0500 Subject: [PATCH] Fixed cn_props ETL, lightning startup and more --- dist/setup.sh | 2 +- proxy_docker/app/data/cyphernode.postgresql | 2 +- .../data/sqlmigrate20211105_0.7.0-0.8.0.sh | 22 +++++++++---------- ...te20211105_0.7.0-0.8.0_sqlite3-extract.sql | 7 ++++-- proxy_docker/app/script/batching.sh | 2 +- proxy_docker/app/script/waitanyinvoice.sh | 11 +++++++++- 6 files changed, 29 insertions(+), 17 deletions(-) diff --git a/dist/setup.sh b/dist/setup.sh index 263c669..fef0567 100755 --- a/dist/setup.sh +++ b/dist/setup.sh @@ -855,7 +855,7 @@ SUDO_REQUIRED=0 AUTOSTART=0 # CYPHERNODE VERSION "v0.7.0-dev" -SETUP_VERSION="dev-on-v0.7.0" +SETUP_VERSION="v0.7.0-dev" CONF_VERSION="v0.7.0-dev" GATEKEEPER_VERSION="v0.7.0-dev" TOR_VERSION="v0.7.0-dev" diff --git a/proxy_docker/app/data/cyphernode.postgresql b/proxy_docker/app/data/cyphernode.postgresql index 18f649c..6f3e256 100644 --- a/proxy_docker/app/data/cyphernode.postgresql +++ b/proxy_docker/app/data/cyphernode.postgresql @@ -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, diff --git a/proxy_docker/app/data/sqlmigrate20211105_0.7.0-0.8.0.sh b/proxy_docker/app/data/sqlmigrate20211105_0.7.0-0.8.0.sh index 93d3ffd..a845ac7 100644 --- a/proxy_docker/app/data/sqlmigrate20211105_0.7.0-0.8.0.sh +++ b/proxy_docker/app/data/sqlmigrate20211105_0.7.0-0.8.0.sh @@ -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..." diff --git a/proxy_docker/app/data/sqlmigrate20211105_0.7.0-0.8.0_sqlite3-extract.sql b/proxy_docker/app/data/sqlmigrate20211105_0.7.0-0.8.0_sqlite3-extract.sql index 61a8265..e96e028 100644 --- a/proxy_docker/app/data/sqlmigrate20211105_0.7.0-0.8.0_sqlite3-extract.sql +++ b/proxy_docker/app/data/sqlmigrate20211105_0.7.0-0.8.0_sqlite3-extract.sql @@ -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 diff --git a/proxy_docker/app/script/batching.sh b/proxy_docker/app/script/batching.sh index 3e27a0f..33bc770 100644 --- a/proxy_docker/app/script/batching.sh +++ b/proxy_docker/app/script/batching.sh @@ -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 diff --git a/proxy_docker/app/script/waitanyinvoice.sh b/proxy_docker/app/script/waitanyinvoice.sh index 2f4be3a..52ffc83 100644 --- a/proxy_docker/app/script/waitanyinvoice.sh +++ b/proxy_docker/app/script/waitanyinvoice.sh @@ -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