sync

Backup service to store encrypted wallet databases (experimental)
Log | Files | Refs | Submodules | README | LICENSE

commit eac3954b9781f454fea9d0a3cecb507dd5376c65
parent 6be561d0b01f65c4c1eb931dd0d8d45ee83aedf7
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat, 29 Jul 2023 16:33:13 +0200

migrate sync to use amount tuples

Diffstat:
Msrc/syncdb/plugin_syncdb_postgres.c | 14++++++--------
Msrc/syncdb/sync-0001.sql | 13++++++++++---
2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/src/syncdb/plugin_syncdb_postgres.c b/src/syncdb/plugin_syncdb_postgres.c @@ -123,10 +123,9 @@ prepare_statements (void *cls) ",order_id" ",token" ",timestamp" - ",amount_val" - ",amount_frac" + ",amount" ") VALUES " - "($1,$2,$3,$4,$5,$6);"), + "($1,$2,$3,$4,$5);"), GNUNET_PQ_make_prepare ("payment_done", "UPDATE payments " "SET" @@ -154,8 +153,7 @@ prepare_statements (void *cls) "SELECT" " account_pub" ",order_id" - ",amount_val" - ",amount_frac" + ",amount" " FROM payments" " WHERE paid=FALSE;"), GNUNET_PQ_make_prepare ("payments_select_by_account", @@ -163,8 +161,7 @@ prepare_statements (void *cls) " timestamp" ",order_id" ",token" - ",amount_val" - ",amount_frac" + ",amount" " FROM payments" " WHERE" " paid=FALSE" @@ -505,7 +502,8 @@ postgres_store_payment (void *cls, GNUNET_PQ_query_param_string (order_id), GNUNET_PQ_query_param_auto_from_type (&tok), GNUNET_PQ_query_param_timestamp (&now), - TALER_PQ_query_param_amount (amount), + TALER_PQ_query_param_amount_tuple (pg->conn, + amount), GNUNET_PQ_query_param_end }; diff --git a/src/syncdb/sync-0001.sql b/src/syncdb/sync-0001.sql @@ -1,6 +1,6 @@ -- -- This file is part of TALER --- Copyright (C) 2021 Taler Systems SA +-- Copyright (C) 2021, 2023 Taler Systems SA -- -- TALER is free software; you can redistribute it and/or modify it under the -- terms of the GNU General Public License as published by the Free Software @@ -25,6 +25,14 @@ COMMENT ON SCHEMA sync IS 'sync data'; SET search_path TO sync; +CREATE TYPE taler_amount + AS + (val INT8 + ,frac INT4 + ); +COMMENT ON TYPE taler_amount + IS 'Stores an amount, fraction is in units of 1/100000000 of the base value'; + CREATE TABLE IF NOT EXISTS accounts (account_pub BYTEA PRIMARY KEY CHECK (length(account_pub)=32) ,expiration_date INT8 NOT NULL); @@ -38,8 +46,7 @@ CREATE TABLE IF NOT EXISTS payments ,order_id VARCHAR PRIMARY KEY ,token BYTEA CHECK (length(token)=16) ,timestamp INT8 NOT NULL - ,amount_val INT8 NOT NULL - ,amount_frac INT4 NOT NULL + ,amount taler_amount NOT NULL ,paid BOOLEAN NOT NULL DEFAULT FALSE); CREATE INDEX IF NOT EXISTS payments_timestamp ON