Small LN refactoring and retrying SQL requests on failures...

This commit is contained in:
kexkey
2021-10-27 15:01:58 -04:00
parent fc3fadf59f
commit 801af8c1ce
3 changed files with 74 additions and 72 deletions

View File

@@ -3,17 +3,27 @@
. ./trace.sh
sql() {
trace "sqlite3 -cmd \".timeout 25000\" ${DB_FILE} \"${1}\""
sqlite3 -cmd ".timeout 25000" ${DB_FILE} "${1}"
# sqlite3 ${DB_FILE} "PRAGMA busy_timeout=20000; ${1}"
trace "sqlite3 -cmd \".timeout 40000\" ${DB_FILE} \"${1}\""
sqlite3 -cmd ".timeout 40000" ${DB_FILE} "${1}"
return $?
if [ "$?" -ne 0 ]; then
# SQL didn't work, let's retry to be sure...
trace "SQL didn't work, let's retry..."
sqlite3 -cmd ".timeout 40000" ${DB_FILE} "${1}"
fi
return $?
}
sql_rawtx() {
trace "sqlite3 -cmd \".timeout 25000\" ${DB_FILE}_rawtx \"${1}\""
sqlite3 -cmd ".timeout 25000" ${DB_FILE}_rawtx "${1}"
# sqlite3 ${DB_FILE} "PRAGMA busy_timeout=20000; ${1}"
trace "sqlite3 -cmd \".timeout 40000\" ${DB_FILE}_rawtx \"${1}\""
sqlite3 -cmd ".timeout 40000" ${DB_FILE}_rawtx "${1}"
return $?
if [ "$?" -ne 0 ]; then
# SQL didn't work, let's retry to be sure...
trace "SQL didn't work, let's retry..."
sqlite3 -cmd ".timeout 40000" ${DB_FILE}_rawtx "${1}"
fi
return $?
}