sync tables "extensions" and "extension_details" with auditor
This commit is contained in:
parent
43f8ab6b48
commit
8a906bf96c
@ -111,6 +111,8 @@ static struct Table tables[] = {
|
|||||||
{ .rt = TALER_EXCHANGEDB_RT_WIRE_FEE},
|
{ .rt = TALER_EXCHANGEDB_RT_WIRE_FEE},
|
||||||
{ .rt = TALER_EXCHANGEDB_RT_RECOUP},
|
{ .rt = TALER_EXCHANGEDB_RT_RECOUP},
|
||||||
{ .rt = TALER_EXCHANGEDB_RT_RECOUP_REFRESH },
|
{ .rt = TALER_EXCHANGEDB_RT_RECOUP_REFRESH },
|
||||||
|
{ .rt = TALER_EXCHANGEDB_RT_EXTENSIONS},
|
||||||
|
{ .rt = TALER_EXCHANGEDB_RT_EXTENSION_DETAILS },
|
||||||
{ .end = true }
|
{ .end = true }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -702,4 +702,55 @@ irbt_cb_table_recoup_refresh (struct PostgresClosure *pg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function called with extensions records to insert into table.
|
||||||
|
*
|
||||||
|
* @param pg plugin context
|
||||||
|
* @param td record to insert
|
||||||
|
*/
|
||||||
|
static enum GNUNET_DB_QueryStatus
|
||||||
|
irbt_cb_table_extensions (struct PostgresClosure *pg,
|
||||||
|
const struct TALER_EXCHANGEDB_TableData *td)
|
||||||
|
{
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_uint64 (&td->serial),
|
||||||
|
GNUNET_PQ_query_param_string (td->details.extensions.name),
|
||||||
|
NULL == td->details.extensions.config ?
|
||||||
|
GNUNET_PQ_query_param_null () :
|
||||||
|
GNUNET_PQ_query_param_string (td->details.extensions.config),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"insert_into_table_extensions",
|
||||||
|
params);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function called with extension_details records to insert into table.
|
||||||
|
*
|
||||||
|
* @param pg plugin context
|
||||||
|
* @param td record to insert
|
||||||
|
*/
|
||||||
|
static enum GNUNET_DB_QueryStatus
|
||||||
|
irbt_cb_table_extension_details (struct PostgresClosure *pg,
|
||||||
|
const struct TALER_EXCHANGEDB_TableData *td)
|
||||||
|
{
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_uint64 (&td->serial),
|
||||||
|
NULL ==
|
||||||
|
td->details.extension_details.extension_options ?
|
||||||
|
GNUNET_PQ_query_param_null () :
|
||||||
|
GNUNET_PQ_query_param_string (
|
||||||
|
td->details.extension_details.extension_options),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"insert_into_table_extension_details",
|
||||||
|
params);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* end of irbt_callbacks.c */
|
/* end of irbt_callbacks.c */
|
||||||
|
@ -1306,4 +1306,99 @@ lrbt_cb_table_recoup_refresh (void *cls,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function called with extensions table entries.
|
||||||
|
*
|
||||||
|
* @param cls closure
|
||||||
|
* @param result the postgres result
|
||||||
|
* @param num_results the number of results in @a result
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
lrbt_cb_table_extensions (void *cls,
|
||||||
|
PGresult *result,
|
||||||
|
unsigned int num_results)
|
||||||
|
{
|
||||||
|
struct LookupRecordsByTableContext *ctx = cls;
|
||||||
|
struct TALER_EXCHANGEDB_TableData td = {
|
||||||
|
.table = TALER_EXCHANGEDB_RT_EXTENSIONS
|
||||||
|
};
|
||||||
|
bool no_config = false;
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i<num_results; i++)
|
||||||
|
{
|
||||||
|
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("extension_id",
|
||||||
|
&td.serial),
|
||||||
|
GNUNET_PQ_result_spec_string ("name",
|
||||||
|
&td.details.extensions.name),
|
||||||
|
GNUNET_PQ_result_spec_allow_null (
|
||||||
|
GNUNET_PQ_result_spec_string ("config",
|
||||||
|
&td.details.extensions.config),
|
||||||
|
&no_config),
|
||||||
|
GNUNET_PQ_result_spec_end
|
||||||
|
};
|
||||||
|
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
GNUNET_PQ_extract_result (result,
|
||||||
|
rs,
|
||||||
|
i))
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
ctx->error = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ctx->cb (ctx->cb_cls,
|
||||||
|
&td);
|
||||||
|
GNUNET_PQ_cleanup_result (rs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function called with extension_details table entries.
|
||||||
|
*
|
||||||
|
* @param cls closure
|
||||||
|
* @param result the postgres result
|
||||||
|
* @param num_results the number of results in @a result
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
lrbt_cb_table_extension_details (void *cls,
|
||||||
|
PGresult *result,
|
||||||
|
unsigned int num_results)
|
||||||
|
{
|
||||||
|
struct LookupRecordsByTableContext *ctx = cls;
|
||||||
|
struct TALER_EXCHANGEDB_TableData td = {
|
||||||
|
.table = TALER_EXCHANGEDB_RT_EXTENSION_DETAILS
|
||||||
|
};
|
||||||
|
bool no_config = false;
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i<num_results; i++)
|
||||||
|
{
|
||||||
|
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("extension_details_serial_id",
|
||||||
|
&td.serial),
|
||||||
|
GNUNET_PQ_result_spec_allow_null (
|
||||||
|
GNUNET_PQ_result_spec_string ("extension_options",
|
||||||
|
&td.details.extension_details.
|
||||||
|
extension_options),
|
||||||
|
&no_config),
|
||||||
|
GNUNET_PQ_result_spec_end
|
||||||
|
};
|
||||||
|
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
GNUNET_PQ_extract_result (result,
|
||||||
|
rs,
|
||||||
|
i))
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
ctx->error = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ctx->cb (ctx->cb_cls,
|
||||||
|
&td);
|
||||||
|
GNUNET_PQ_cleanup_result (rs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* end of lrbt_callbacks.c */
|
/* end of lrbt_callbacks.c */
|
||||||
|
@ -2123,6 +2123,22 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
" ORDER BY recoup_refresh_uuid DESC"
|
" ORDER BY recoup_refresh_uuid DESC"
|
||||||
" LIMIT 1;",
|
" LIMIT 1;",
|
||||||
0),
|
0),
|
||||||
|
GNUNET_PQ_make_prepare (
|
||||||
|
"select_serial_by_table_extensions",
|
||||||
|
"SELECT"
|
||||||
|
" extension_id AS serial"
|
||||||
|
" FROM extensions"
|
||||||
|
" ORDER BY extension_id DESC"
|
||||||
|
" LIMIT 1;",
|
||||||
|
0),
|
||||||
|
GNUNET_PQ_make_prepare (
|
||||||
|
"select_serial_by_table_extension_details",
|
||||||
|
"SELECT"
|
||||||
|
" extension_details_serial_id AS serial"
|
||||||
|
" FROM extension_details"
|
||||||
|
" ORDER BY extension_details_serial_id DESC"
|
||||||
|
" LIMIT 1;",
|
||||||
|
0),
|
||||||
/* For postgres_lookup_records_by_table */
|
/* For postgres_lookup_records_by_table */
|
||||||
GNUNET_PQ_make_prepare (
|
GNUNET_PQ_make_prepare (
|
||||||
"select_above_serial_by_table_denominations",
|
"select_above_serial_by_table_denominations",
|
||||||
@ -2727,6 +2743,23 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
") VALUES "
|
") VALUES "
|
||||||
"($1, $2, $3, $4, $5, $6, $7, $8);",
|
"($1, $2, $3, $4, $5, $6, $7, $8);",
|
||||||
8),
|
8),
|
||||||
|
GNUNET_PQ_make_prepare (
|
||||||
|
"insert_into_table_extensions",
|
||||||
|
"INSERT INTO extensions"
|
||||||
|
"(extension_id"
|
||||||
|
",name"
|
||||||
|
",config"
|
||||||
|
") VALUES "
|
||||||
|
"($1, $2, $3);",
|
||||||
|
3),
|
||||||
|
GNUNET_PQ_make_prepare (
|
||||||
|
"insert_into_table_extension_details",
|
||||||
|
"INSERT INTO extension_details"
|
||||||
|
"(extension_details_serial_id"
|
||||||
|
",extension_options"
|
||||||
|
") VALUES "
|
||||||
|
"($1, $2);",
|
||||||
|
2),
|
||||||
|
|
||||||
/* Used in #postgres_begin_shard() */
|
/* Used in #postgres_begin_shard() */
|
||||||
GNUNET_PQ_make_prepare (
|
GNUNET_PQ_make_prepare (
|
||||||
@ -10807,6 +10840,12 @@ postgres_lookup_serial_by_table (void *cls,
|
|||||||
case TALER_EXCHANGEDB_RT_RECOUP_REFRESH:
|
case TALER_EXCHANGEDB_RT_RECOUP_REFRESH:
|
||||||
statement = "select_serial_by_table_recoup_refresh";
|
statement = "select_serial_by_table_recoup_refresh";
|
||||||
break;
|
break;
|
||||||
|
case TALER_EXCHANGEDB_RT_EXTENSIONS:
|
||||||
|
statement = "select_serial_by_table_extensions";
|
||||||
|
break;
|
||||||
|
case TALER_EXCHANGEDB_RT_EXTENSION_DETAILS:
|
||||||
|
statement = "select_serial_by_table_extension_details";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return GNUNET_DB_STATUS_HARD_ERROR;
|
return GNUNET_DB_STATUS_HARD_ERROR;
|
||||||
@ -10972,6 +11011,14 @@ postgres_lookup_records_by_table (void *cls,
|
|||||||
statement = "select_above_serial_by_table_recoup_refresh";
|
statement = "select_above_serial_by_table_recoup_refresh";
|
||||||
rh = &lrbt_cb_table_recoup_refresh;
|
rh = &lrbt_cb_table_recoup_refresh;
|
||||||
break;
|
break;
|
||||||
|
case TALER_EXCHANGEDB_RT_EXTENSIONS:
|
||||||
|
statement = "select_above_serial_by_table_extensions";
|
||||||
|
rh = &lrbt_cb_table_extensions;
|
||||||
|
break;
|
||||||
|
case TALER_EXCHANGEDB_RT_EXTENSION_DETAILS:
|
||||||
|
statement = "select_above_serial_by_table_extension_details";
|
||||||
|
rh = &lrbt_cb_table_extension_details;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return GNUNET_DB_STATUS_HARD_ERROR;
|
return GNUNET_DB_STATUS_HARD_ERROR;
|
||||||
@ -11097,6 +11144,12 @@ postgres_insert_records_by_table (void *cls,
|
|||||||
case TALER_EXCHANGEDB_RT_RECOUP_REFRESH:
|
case TALER_EXCHANGEDB_RT_RECOUP_REFRESH:
|
||||||
rh = &irbt_cb_table_recoup_refresh;
|
rh = &irbt_cb_table_recoup_refresh;
|
||||||
break;
|
break;
|
||||||
|
case TALER_EXCHANGEDB_RT_EXTENSIONS:
|
||||||
|
rh = &irbt_cb_table_extensions;
|
||||||
|
break;
|
||||||
|
case TALER_EXCHANGEDB_RT_EXTENSION_DETAILS:
|
||||||
|
rh = &irbt_cb_table_extension_details;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return GNUNET_DB_STATUS_HARD_ERROR;
|
return GNUNET_DB_STATUS_HARD_ERROR;
|
||||||
|
@ -169,7 +169,9 @@ enum TALER_EXCHANGEDB_ReplicatedTable
|
|||||||
TALER_EXCHANGEDB_RT_AGGREGATION_TRACKING,
|
TALER_EXCHANGEDB_RT_AGGREGATION_TRACKING,
|
||||||
TALER_EXCHANGEDB_RT_WIRE_FEE,
|
TALER_EXCHANGEDB_RT_WIRE_FEE,
|
||||||
TALER_EXCHANGEDB_RT_RECOUP,
|
TALER_EXCHANGEDB_RT_RECOUP,
|
||||||
TALER_EXCHANGEDB_RT_RECOUP_REFRESH
|
TALER_EXCHANGEDB_RT_RECOUP_REFRESH,
|
||||||
|
TALER_EXCHANGEDB_RT_EXTENSIONS,
|
||||||
|
TALER_EXCHANGEDB_RT_EXTENSION_DETAILS,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -407,6 +409,17 @@ struct TALER_EXCHANGEDB_TableData
|
|||||||
uint64_t rrc_serial;
|
uint64_t rrc_serial;
|
||||||
} recoup_refresh;
|
} recoup_refresh;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
char *name;
|
||||||
|
char *config;
|
||||||
|
} extensions;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
char *extension_options;
|
||||||
|
} extension_details;
|
||||||
|
|
||||||
} details;
|
} details;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user