commit d5064432f3e1794e7f9c1ae3d5d0f28162c3d960
parent 122f207c2ea86e9eab061034eab968b4eaa68391
Author: Casaburi Johannes <johannes.casaburi@students.bfh.ch>
Date: Thu, 30 May 2024 16:10:34 +0200
doc db, work on submit
Diffstat:
4 files changed, 32 insertions(+), 7 deletions(-)
diff --git a/doc/thesis/chapters/implementation/implementation.tex b/doc/thesis/chapters/implementation/implementation.tex
@@ -46,13 +46,14 @@ Even the donation statement will not be returned after a submit request, a donat
The REST client removes some of the complexity of sending requests to the Donau Server. It converts request parameters into JSON and parses JSON responses into a usable C format. What the exact queries are and how they look like is already described in the chapter xx Donau REST API.
\subsection{Donau Database}
-The Donau database is shown in the figure below:
+The Donau database contains five tables as shown in the figure below. The \texttt{donation\_units} and \texttt{donau\_sign\_keys} table store the keys necessary for signing and creating donation receipts. Donation receipts that are issued to be signed by the donau are stored in the \texttt{receipts\_issued} table while the receipts that are already signed are stored in the \texttt{receipts\_submitted} table. The \texttt{history} table keeps the donation records of the past years.
+
\begin{figure}[ht]
\includegraphics[width=1\textwidth]{db_physical_model}
\caption{database physical model} \label{fig:db_physical_model}
\end{figure}
\subsubsection{charities}
-Each registered charity has an entry in this table.
+Each registered charity has an entry in this table. There may be a donation limit imposed by local law which prevents further donations if the limit is reached.
\begin{itemize}
\item \texttt{charity\_id:} Unique ID generated by the database.
\item \texttt{charity\_pub:} Charity EdDSA public key
@@ -94,7 +95,7 @@ Contains all issued donation receipts sent to the Donau.
\end{itemize}
\subsubsection{receipts\_submitted}
-Contains all submitted donation receipts sent to the Donor.
+Contains all submitted donation receipts sent to the Donor. By storing the signature \texttt{donation\_unit\_sig}, the idempotentcy of the API is kept in case the private key is replaced.
\begin{itemize}
\item \texttt{receipt\_id:} Unique ID generated by the database.
\item \texttt{h\_tax\_number:} The hash of the tax number and salt.
@@ -105,7 +106,7 @@ Contains all submitted donation receipts sent to the Donor.
\end{itemize}
\subsubsection{history}
-History of the yearly donations for each charity.
+History of the yearly donations for each charity. This data provides a record of donations each year. It could also provide valuable information that could be used in statistics to analize general donations over the year.
\begin{itemize}
\item \texttt{charity\_id:} Unique ID generated by the database.
\item \texttt{final\_amount:} The final amount that was donated to the charity
diff --git a/doc/thesis/thesis.pdf b/doc/thesis/thesis.pdf
Binary files differ.
diff --git a/src/donau/donau-httpd_batch-submit.c b/src/donau/donau-httpd_batch-submit.c
@@ -145,10 +145,25 @@ DH_handler_submit_receipts_post (struct DH_RequestContext *rc,
for (size_t i = 0; i < num_dr; i++)
{
- // FIXME Check nonce
struct DONAU_UniqueDonorIdentifierHashP udi_hash;
struct DH_DonationUnitKey *dk;
+ /* Check nonce unique*/
+ for (size_t j = i + 1; j < num_dr; j++)
+ {
+ if (irc.donation_receipts[i].nonce.value == irc.donation_receipts[j].nonce
+ .value)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Donation receipt nonce is not unique!\n");
+ return TALER_MHD_reply_with_error (rc->connection,
+ MHD_HTTP_CONFLICT,
+ TALER_EC_DONAU_DONOR_IDENTIFIER_NONCE_REUSE,
+ NULL);
+ }
+ }
+
+ /* Check if donation unit exists*/
if (NULL == (dk = DH_keys_donation_unit_by_hash (
&irc.donation_receipts[i].h_donation_unit_pub)))
{
diff --git a/src/donaudb/pg_insert_submitted_receipts.c b/src/donaudb/pg_insert_submitted_receipts.c
@@ -54,7 +54,7 @@ DH_PG_insert_submitted_receipts (
GNUNET_PQ_query_param_end
};
- bool *conflicted[GNUNET_NZL (num_dr)];
+ bool conflicted[GNUNET_NZL (num_dr)];
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_auto_array_from_type (pg->conn,
"conflicted",
@@ -89,6 +89,15 @@ DH_PG_insert_submitted_receipts (
params,
rs);
GNUNET_PQ_cleanup_query_params_closures (params);
- // FIXME log conflicted rs
+
+ for (size_t i = 0; i < num_dr; i++)
+ {
+ if (conflicted[i])
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Submitted donation receipt at index %ld already present!\n",
+ i);
+ }
+ }
return qs;
}