fix history API
This commit is contained in:
parent
4ac34199ad
commit
d7ccfad610
@ -1 +1 @@
|
|||||||
Subproject commit ca53235ccfa0458ebf11c204888ca370e20ec3f5
|
Subproject commit 934a6a18301e81c4fd1b3a8cda2dc13dca4741cc
|
@ -16,7 +16,6 @@
|
|||||||
License along with TALER; see the file COPYING. If not,
|
License along with TALER; see the file COPYING. If not,
|
||||||
see <http://www.gnu.org/licenses/>
|
see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file bank-lib/fakebank.c
|
* @file bank-lib/fakebank.c
|
||||||
* @brief library that fakes being a Taler bank for testcases
|
* @brief library that fakes being a Taler bank for testcases
|
||||||
@ -426,12 +425,6 @@ TALER_FAKEBANK_make_admin_transfer (struct TALER_FAKEBANK_Handle *h,
|
|||||||
GNUNET_break (0 != strncasecmp ("payto://",
|
GNUNET_break (0 != strncasecmp ("payto://",
|
||||||
credit_account,
|
credit_account,
|
||||||
strlen ("payto://")));
|
strlen ("payto://")));
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
|
||||||
"Making transfer from %s to %s over %s and subject %s\n",
|
|
||||||
debit_account,
|
|
||||||
credit_account,
|
|
||||||
TALER_amount2s (amount),
|
|
||||||
TALER_B2S (reserve_pub));
|
|
||||||
t = GNUNET_new (struct Transaction);
|
t = GNUNET_new (struct Transaction);
|
||||||
t->debit_account = GNUNET_strdup (debit_account);
|
t->debit_account = GNUNET_strdup (debit_account);
|
||||||
t->credit_account = GNUNET_strdup (credit_account);
|
t->credit_account = GNUNET_strdup (credit_account);
|
||||||
@ -444,6 +437,13 @@ TALER_FAKEBANK_make_admin_transfer (struct TALER_FAKEBANK_Handle *h,
|
|||||||
GNUNET_CONTAINER_DLL_insert_tail (h->transactions_head,
|
GNUNET_CONTAINER_DLL_insert_tail (h->transactions_head,
|
||||||
h->transactions_tail,
|
h->transactions_tail,
|
||||||
t);
|
t);
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
|
"Making transfer from %s to %s over %s and subject %s at row %llu\n",
|
||||||
|
debit_account,
|
||||||
|
credit_account,
|
||||||
|
TALER_amount2s (amount),
|
||||||
|
TALER_B2S (reserve_pub),
|
||||||
|
(unsigned long long) t->row_id);
|
||||||
return t->row_id;
|
return t->row_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -612,17 +612,17 @@ handle_admin_add_incoming (struct TALER_FAKEBANK_Handle *h,
|
|||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
debit = TALER_xtalerbank_account_from_payto (debit_account);
|
debit = TALER_xtalerbank_account_from_payto (debit_account);
|
||||||
row_id = TALER_FAKEBANK_make_admin_transfer (h,
|
|
||||||
debit,
|
|
||||||
account,
|
|
||||||
&amount,
|
|
||||||
&reserve_pub);
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
"Receiving incoming wire transfer: %s->%s, subject: %s, amount: %s\n",
|
"Receiving incoming wire transfer: %s->%s, subject: %s, amount: %s\n",
|
||||||
debit,
|
debit,
|
||||||
account,
|
account,
|
||||||
TALER_B2S (&reserve_pub),
|
TALER_B2S (&reserve_pub),
|
||||||
TALER_amount2s (&amount));
|
TALER_amount2s (&amount));
|
||||||
|
row_id = TALER_FAKEBANK_make_admin_transfer (h,
|
||||||
|
debit,
|
||||||
|
account,
|
||||||
|
&amount,
|
||||||
|
&reserve_pub);
|
||||||
GNUNET_free (debit);
|
GNUNET_free (debit);
|
||||||
}
|
}
|
||||||
json_decref (json);
|
json_decref (json);
|
||||||
@ -870,6 +870,11 @@ parse_history_common_args (struct MHD_Connection *connection,
|
|||||||
else
|
else
|
||||||
ha->start_idx = (uint64_t) sval;
|
ha->start_idx = (uint64_t) sval;
|
||||||
ha->delta = (int64_t) d;
|
ha->delta = (int64_t) d;
|
||||||
|
if (0 == ha->delta)
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
return GNUNET_NO;
|
||||||
|
}
|
||||||
ha->lp_timeout
|
ha->lp_timeout
|
||||||
= GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
|
= GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
|
||||||
lp_timeout);
|
lp_timeout);
|
||||||
@ -923,9 +928,9 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h,
|
|||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
/* range is exclusive, skip the matching entry */
|
/* range is exclusive, skip the matching entry */
|
||||||
if (ha.delta > 0)
|
if (0 > ha.delta)
|
||||||
pos = pos->next;
|
pos = pos->prev;
|
||||||
if (ha.delta < 0)
|
else
|
||||||
pos = pos->prev;
|
pos = pos->prev;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -970,9 +975,9 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h,
|
|||||||
else
|
else
|
||||||
ha.delta++;
|
ha.delta++;
|
||||||
}
|
}
|
||||||
if (ha.delta > 0)
|
if (0 > ha.delta)
|
||||||
pos = pos->prev;
|
pos = pos->prev;
|
||||||
else
|
if (0 < ha.delta)
|
||||||
pos = pos->next;
|
pos = pos->next;
|
||||||
}
|
}
|
||||||
return TALER_MHD_reply_json_pack (connection,
|
return TALER_MHD_reply_json_pack (connection,
|
||||||
@ -1018,8 +1023,17 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
|
|||||||
for (pos = h->transactions_head;
|
for (pos = h->transactions_head;
|
||||||
NULL != pos;
|
NULL != pos;
|
||||||
pos = pos->next)
|
pos = pos->next)
|
||||||
|
{
|
||||||
if (pos->row_id == ha.start_idx)
|
if (pos->row_id == ha.start_idx)
|
||||||
break;
|
break;
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
|
"Skipping transaction %s->%s (%s) at %llu (looking for start index %llu)\n",
|
||||||
|
pos->debit_account,
|
||||||
|
pos->credit_account,
|
||||||
|
TALER_B2S (&pos->subject.credit.reserve_pub),
|
||||||
|
(unsigned long long) pos->row_id,
|
||||||
|
(unsigned long long) ha.start_idx);
|
||||||
|
}
|
||||||
if (NULL == pos)
|
if (NULL == pos)
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
@ -1028,10 +1042,16 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
|
|||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
/* range is exclusive, skip the matching entry */
|
/* range is exclusive, skip the matching entry */
|
||||||
if (ha.delta > 0)
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
pos = pos->next;
|
"Skipping transaction %s->%s (%s) (start index %llu is exclusive)\n",
|
||||||
if (ha.delta < 0)
|
pos->debit_account,
|
||||||
|
pos->credit_account,
|
||||||
|
TALER_B2S (&pos->subject.credit.reserve_pub),
|
||||||
|
(unsigned long long) ha.start_idx);
|
||||||
|
if (0 > ha.delta)
|
||||||
pos = pos->prev;
|
pos = pos->prev;
|
||||||
|
else
|
||||||
|
pos = pos->next;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1055,10 +1075,11 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
|
|||||||
debit_payto = TALER_payto_xtalerbank_make (h->my_baseurl,
|
debit_payto = TALER_payto_xtalerbank_make (h->my_baseurl,
|
||||||
pos->debit_account);
|
pos->debit_account);
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
"Returning transaction %s->%s (%s)\n",
|
"Returning transaction %s->%s (%s) at %llu\n",
|
||||||
debit_payto,
|
pos->debit_account,
|
||||||
credit_payto,
|
pos->credit_account,
|
||||||
TALER_B2S (&pos->subject));
|
TALER_B2S (&pos->subject.credit.reserve_pub),
|
||||||
|
(unsigned long long) pos->row_id);
|
||||||
trans = json_pack
|
trans = json_pack
|
||||||
("{s:I, s:o, s:o, s:s, s:s, s:o}",
|
("{s:I, s:o, s:o, s:s, s:s, s:o}",
|
||||||
"row_id", (json_int_t) pos->row_id,
|
"row_id", (json_int_t) pos->row_id,
|
||||||
@ -1067,7 +1088,7 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
|
|||||||
"credit_account", credit_payto,
|
"credit_account", credit_payto,
|
||||||
"debit_account", debit_payto,
|
"debit_account", debit_payto,
|
||||||
"reserve_pub", GNUNET_JSON_from_data_auto (
|
"reserve_pub", GNUNET_JSON_from_data_auto (
|
||||||
&pos->subject.credit));
|
&pos->subject.credit.reserve_pub));
|
||||||
GNUNET_free (credit_payto);
|
GNUNET_free (credit_payto);
|
||||||
GNUNET_free (debit_payto);
|
GNUNET_free (debit_payto);
|
||||||
GNUNET_assert (0 ==
|
GNUNET_assert (0 ==
|
||||||
@ -1078,9 +1099,18 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
|
|||||||
else
|
else
|
||||||
ha.delta++;
|
ha.delta++;
|
||||||
}
|
}
|
||||||
if (ha.delta > 0)
|
else if (T_CREDIT == pos->type)
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
|
"Skipping transaction %s->%s (%s) at row %llu\n",
|
||||||
|
pos->debit_account,
|
||||||
|
pos->credit_account,
|
||||||
|
TALER_B2S (&pos->subject.credit.reserve_pub),
|
||||||
|
(unsigned long long) pos->row_id);
|
||||||
|
}
|
||||||
|
if (0 > ha.delta)
|
||||||
pos = pos->prev;
|
pos = pos->prev;
|
||||||
else
|
if (0 < ha.delta)
|
||||||
pos = pos->next;
|
pos = pos->next;
|
||||||
}
|
}
|
||||||
return TALER_MHD_reply_json_pack (connection,
|
return TALER_MHD_reply_json_pack (connection,
|
||||||
|
@ -231,24 +231,9 @@ withdraw_transaction (void *cls,
|
|||||||
|
|
||||||
/* Check if balance is sufficient */
|
/* Check if balance is sufficient */
|
||||||
r.pub = wc->wsrd.reserve_pub;
|
r.pub = wc->wsrd.reserve_pub;
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
/**
|
"Trying to withdraw from reserve: %s\n",
|
||||||
* Debug block.
|
TALER_B2S (&r.pub));
|
||||||
*/
|
|
||||||
{
|
|
||||||
#define PUBSIZE 80
|
|
||||||
char pub_s[PUBSIZE];
|
|
||||||
|
|
||||||
GNUNET_break
|
|
||||||
(NULL != GNUNET_STRINGS_data_to_string (&r.pub,
|
|
||||||
sizeof (r.pub),
|
|
||||||
&pub_s[0],
|
|
||||||
PUBSIZE));
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
|
||||||
"Trying to withdraw from reserve: %s\n",
|
|
||||||
pub_s);
|
|
||||||
}
|
|
||||||
|
|
||||||
qs = TEH_plugin->reserve_get (TEH_plugin->cls,
|
qs = TEH_plugin->reserve_get (TEH_plugin->cls,
|
||||||
session,
|
session,
|
||||||
&r);
|
&r);
|
||||||
|
@ -60,8 +60,8 @@ batch_run (void *cls,
|
|||||||
struct BatchState *bs = cls;
|
struct BatchState *bs = cls;
|
||||||
|
|
||||||
if (NULL != bs->batch[bs->batch_ip].label)
|
if (NULL != bs->batch[bs->batch_ip].label)
|
||||||
TALER_LOG_DEBUG ("Running batched command: %s\n",
|
TALER_LOG_INFO ("Running batched command: %s\n",
|
||||||
bs->batch[bs->batch_ip].label);
|
bs->batch[bs->batch_ip].label);
|
||||||
|
|
||||||
/* hit end command, leap to next top-level command. */
|
/* hit end command, leap to next top-level command. */
|
||||||
if (NULL == bs->batch[bs->batch_ip].label)
|
if (NULL == bs->batch[bs->batch_ip].label)
|
||||||
|
Loading…
Reference in New Issue
Block a user