diff options
author | Christian Grothoff <grothoff@gnunet.org> | 2021-11-01 18:05:01 +0100 |
---|---|---|
committer | Christian Grothoff <grothoff@gnunet.org> | 2021-11-01 18:05:01 +0100 |
commit | 22ce5bff77e922bc0f679e7f450a66dc5f27f148 (patch) | |
tree | a01fe1b0c859869559d4fffb7315fc210a9b4ec3 /src/exchangedb | |
parent | 5b3a468d3878a2d0e39dd71da07d0fd85544632e (diff) |
fix sharding
Diffstat (limited to 'src/exchangedb')
-rw-r--r-- | src/exchangedb/exchange-0001.sql | 2 | ||||
-rw-r--r-- | src/exchangedb/plugin_exchangedb_postgres.c | 16 | ||||
-rw-r--r-- | src/exchangedb/test_exchangedb.c | 6 |
3 files changed, 12 insertions, 12 deletions
diff --git a/src/exchangedb/exchange-0001.sql b/src/exchangedb/exchange-0001.sql index 87ac555ba..68eb07336 100644 --- a/src/exchangedb/exchange-0001.sql +++ b/src/exchangedb/exchange-0001.sql @@ -386,7 +386,7 @@ CREATE TABLE IF NOT EXISTS deposits COMMENT ON TABLE deposits IS 'Deposits we have received and for which we need to make (aggregate) wire transfers (and manage refunds).'; COMMENT ON COLUMN deposits.shard - IS 'Used for load sharding. Should be set based on h_wire, merchant_pub and a service salt. Default of 0 onlyapplies for columns migrated from a previous version without sharding support. 64-bit value because we need an *unsigned* 32-bit value.'; + IS 'Used for load sharding. Should be set based on h_payto and merchant_pub. Default of 0 onlyapplies for columns migrated from a previous version without sharding support. 64-bit value because we need an *unsigned* 32-bit value.'; COMMENT ON COLUMN deposits.wire_target_serial_id IS 'Identifies the target bank account and KYC status';COMMENT ON COLUMN deposits.wire_salt IS 'Salt used when hashing the payto://-URI to get the h_wire'; diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index 199c3d333..66bad461b 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -5301,7 +5301,7 @@ postgres_get_ready_deposit (void *cls, (void) GNUNET_TIME_round_abs (&now); GNUNET_assert (start_shard_row < end_shard_row); - GNUNET_assert (end_shard_row <= INT64_MAX); + GNUNET_assert (end_shard_row <= INT32_MAX); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Finding ready deposits by deadline %s (%llu)\n", GNUNET_STRINGS_absolute_time_to_string (now), @@ -5709,7 +5709,7 @@ postgres_ensure_coin_known (void *cls, static uint64_t compute_shard (const struct TALER_EXCHANGEDB_Deposit *deposit) { - uint64_t res; + uint32_t res; GNUNET_assert (GNUNET_YES == GNUNET_CRYPTO_kdf (&res, @@ -5720,12 +5720,12 @@ compute_shard (const struct TALER_EXCHANGEDB_Deposit *deposit) strlen (deposit->receiver_wire_account), NULL, 0)); /* interpret hash result as NBO for platform independence, - convert to HBO and map to [0..2^63-1] range */ + convert to HBO and map to [0..2^31-1] range */ res = ntohl (res); - if (res > INT64_MAX) - res += INT64_MIN; - GNUNET_assert (res <= INT64_MAX); - return res; + if (res > INT32_MAX) + res += INT32_MIN; + GNUNET_assert (res <= INT32_MAX); + return (uint64_t) res; } @@ -5773,7 +5773,7 @@ postgres_insert_deposit (void *cls, GNUNET_PQ_query_param_end }; - GNUNET_assert (shard <= INT64_MAX); + GNUNET_assert (shard <= INT32_MAX); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Inserting deposit to be executed at %s (%llu/%llu)\n", GNUNET_STRINGS_absolute_time_to_string (deposit->wire_deadline), diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index 9b8d1a6d3..44ae56803 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c @@ -1864,7 +1864,7 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->get_ready_deposit (plugin->cls, 0, - INT64_MAX, + INT32_MAX, &deposit_cb, &deposit)); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != @@ -1885,14 +1885,14 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != plugin->get_ready_deposit (plugin->cls, 0, - INT64_MAX, + INT32_MAX, &deposit_cb, &deposit)); plugin->rollback (plugin->cls); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->get_ready_deposit (plugin->cls, 0, - INT64_MAX, + INT32_MAX, &deposit_cb, &deposit)); FAILIF (GNUNET_OK != |