diff options
author | Marcello Stanisci <marcello.stanisci@inria.fr> | 2016-10-12 23:11:54 +0200 |
---|---|---|
committer | Marcello Stanisci <marcello.stanisci@inria.fr> | 2016-10-12 23:11:54 +0200 |
commit | fe973b29bba8a6f46989743e4263a23e473735b8 (patch) | |
tree | 376dc0130aeb7f4edb3dee1519c22a145b50f143 /src/backenddb | |
parent | 52e82c8e9a1a988f075db0c74126744fca548173 (diff) | |
download | merchant-fe973b29bba8a6f46989743e4263a23e473735b8.tar.gz merchant-fe973b29bba8a6f46989743e4263a23e473735b8.tar.bz2 merchant-fe973b29bba8a6f46989743e4263a23e473735b8.zip |
merchant's key in transactions table
Diffstat (limited to 'src/backenddb')
-rw-r--r-- | src/backenddb/plugin_merchantdb_postgres.c | 12 | ||||
-rw-r--r-- | src/backenddb/test_merchantdb.c | 8 |
2 files changed, 17 insertions, 3 deletions
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c index 4c672bd4..821f716e 100644 --- a/src/backenddb/plugin_merchantdb_postgres.c +++ b/src/backenddb/plugin_merchantdb_postgres.c @@ -155,8 +155,9 @@ postgres_initialize (void *cls) /* Setup tables */ PG_EXEC (pg, "CREATE TABLE IF NOT EXISTS merchant_transactions (" - " transaction_id INT8 PRIMARY KEY" + " transaction_id INT8 UNIQUE" ",exchange_uri VARCHAR NOT NULL" + ",merchant_pub BYTEA NOT NULL CHECK (LENGTH(merchant_pub)=32)" ",h_contract BYTEA NOT NULL CHECK (LENGTH(h_contract)=64)" ",h_wire BYTEA NOT NULL CHECK (LENGTH(h_wire)=64)" ",timestamp INT8 NOT NULL" @@ -164,6 +165,7 @@ postgres_initialize (void *cls) ",total_amount_val INT8 NOT NULL" ",total_amount_frac INT4 NOT NULL" ",total_amount_curr VARCHAR(" TALER_CURRENCY_LEN_STR ") NOT NULL" + ",PRIMARY KEY (transaction_id, merchant_pub)" ");"); PG_EXEC (pg, "CREATE TABLE IF NOT EXISTS merchant_deposits (" @@ -211,6 +213,7 @@ postgres_initialize (void *cls) "INSERT INTO merchant_transactions" "(transaction_id" ",exchange_uri" + ",merchant_pub" ",h_contract" ",h_wire" ",timestamp" @@ -219,8 +222,8 @@ postgres_initialize (void *cls) ",total_amount_frac" ",total_amount_curr" ") VALUES " - "($1, $2, $3, $4, $5, $6, $7, $8, $9)", - 9); + "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", + 10); PG_PREPARE (pg, "insert_deposit", "INSERT INTO merchant_deposits" @@ -347,6 +350,7 @@ postgres_initialize (void *cls) * * @param cls closure * @param transaction_id of the contract + * @param merchant_pub merchant's public key * @param exchange_uri URI of the exchange * @param h_contract hash of the contract * @param h_wire hash of our wire details @@ -358,6 +362,7 @@ postgres_initialize (void *cls) static int postgres_store_transaction (void *cls, uint64_t transaction_id, + const struct TALER_MerchantPublicKeyP *merchant_pub, const char *exchange_uri, const struct GNUNET_HashCode *h_contract, const struct GNUNET_HashCode *h_wire, @@ -372,6 +377,7 @@ postgres_store_transaction (void *cls, struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&transaction_id), GNUNET_PQ_query_param_string (exchange_uri), + GNUNET_PQ_query_param_auto_from_type (merchant_pub), GNUNET_PQ_query_param_auto_from_type (h_contract), GNUNET_PQ_query_param_auto_from_type (h_wire), GNUNET_PQ_query_param_absolute_time (×tamp), diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c index 4addef85..15bc3660 100644 --- a/src/backenddb/test_merchantdb.c +++ b/src/backenddb/test_merchantdb.c @@ -110,6 +110,12 @@ static struct TALER_CoinSpendPublicKeyP coin_pub; static struct TALER_ExchangePublicKeyP signkey_pub; /** + * Public Key of the merchant. Set to some random value. + * Used as merchant instances now do store their keys. + */ +static struct TALER_MerchantPublicKeyP merchant_pub; + +/** * Wire transfer identifier. Set to some random value. */ static struct TALER_WireTransferIdentifierRawP wtid; @@ -297,6 +303,7 @@ run (void *cls) RND_BLK (&h_wire); RND_BLK (&transaction_id); RND_BLK (&signkey_pub); + RND_BLK (&merchant_pub); RND_BLK (&wtid); timestamp = GNUNET_TIME_absolute_get(); GNUNET_TIME_round_abs (×tamp); @@ -324,6 +331,7 @@ run (void *cls) FAILIF (GNUNET_OK != plugin->store_transaction (plugin->cls, transaction_id, + &merchant_pub, EXCHANGE_URI, &h_contract, &h_wire, |