mirror of
https://github.com/aljazceru/cyphernode.git
synced 2025-12-18 13:14:56 +01:00
Migrated to postgres and added pub32 tests
This commit is contained in:
@@ -3,6 +3,35 @@
|
||||
. ./trace.sh
|
||||
|
||||
sql() {
|
||||
trace "Entering sql()..."
|
||||
|
||||
local select_id=${2}
|
||||
local response
|
||||
local inserted_id
|
||||
|
||||
trace "[sql] psql -qAtX -h postgres -U cyphernode -c \"${1}\""
|
||||
response=$(psql -qAtX -h postgres -U cyphernode -c "${1}")
|
||||
returncode=$?
|
||||
trace_rc ${returncode}
|
||||
|
||||
if [ -n "${select_id}" ]; then
|
||||
if [ "${returncode}" -eq "0" ]; then
|
||||
inserted_id=$(echo "${response}" | cut -d ' ' -f1)
|
||||
else
|
||||
trace "[sql] psql -qAtX -h postgres -U cyphernode -c \"${select_id}\""
|
||||
inserted_id=$(psql -qAtX -h postgres -U cyphernode -c "${select_id}")
|
||||
returncode=$?
|
||||
trace_rc ${returncode}
|
||||
fi
|
||||
echo -n "${inserted_id}"
|
||||
else
|
||||
echo -n "${response}"
|
||||
fi
|
||||
|
||||
return ${returncode}
|
||||
}
|
||||
|
||||
sql_sqlite() {
|
||||
trace "sqlite3 -cmd \".timeout 40000\" ${DB_FILE} \"${1}\""
|
||||
sqlite3 -cmd ".timeout 40000" ${DB_FILE} "${1}"
|
||||
|
||||
@@ -14,16 +43,3 @@ sql() {
|
||||
|
||||
return $?
|
||||
}
|
||||
|
||||
sql_rawtx() {
|
||||
trace "sqlite3 -cmd \".timeout 40000\" ${DB_FILE}_rawtx \"${1}\""
|
||||
sqlite3 -cmd ".timeout 40000" ${DB_FILE}_rawtx "${1}"
|
||||
|
||||
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 $?
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user