diff options
author | Nic Eigel <nic@eigel.ch> | 2024-01-16 22:37:07 +0100 |
---|---|---|
committer | Nic Eigel <nic@eigel.ch> | 2024-01-16 22:37:07 +0100 |
commit | 45b110edb2b4fd39c56f433c5c0a7f93cd29d4da (patch) | |
tree | 3ce6145e8ea7f67daaa1af55b3651002021167fd /src/auditordb/plugin_auditordb_postgres.c | |
parent | 510d4fc5234e8e17d73e8d95a0dc66ad37c03fef (diff) | |
download | exchange-45b110edb2b4fd39c56f433c5c0a7f93cd29d4da.tar.gz exchange-45b110edb2b4fd39c56f433c5c0a7f93cd29d4da.tar.bz2 exchange-45b110edb2b4fd39c56f433c5c0a7f93cd29d4da.zip |
progress on auditor helpers
Diffstat (limited to 'src/auditordb/plugin_auditordb_postgres.c')
-rw-r--r-- | src/auditordb/plugin_auditordb_postgres.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c index dc66990ba..2366eb69f 100644 --- a/src/auditordb/plugin_auditordb_postgres.c +++ b/src/auditordb/plugin_auditordb_postgres.c @@ -166,6 +166,69 @@ postgres_create_tables (void *cls) /** + * Register callback to be invoked on events of type @a es. + * + * @param cls database context to use + * @param es specification of the event to listen for + * @param timeout how long to wait for the event + * @param cb function to call when the event happens, possibly + * mulrewardle times (until cancel is invoked) + * @param cb_cls closure for @a cb + * @return handle useful to cancel the listener + */ +static struct GNUNET_DB_EventHandler * +postgres_event_listen (void *cls, + const struct GNUNET_DB_EventHeaderP *es, + struct GNUNET_TIME_Relative timeout, + GNUNET_DB_EventCallback cb, + void *cb_cls) +{ + struct PostgresClosure *pg = cls; + + return GNUNET_PQ_event_listen (pg->conn, + es, + timeout, + cb, + cb_cls); +} + + +/** + * Stop notifications. + * + * @param eh handle to unregister. + */ +static void +postgres_event_listen_cancel (struct GNUNET_DB_EventHandler *eh) +{ + GNUNET_PQ_event_listen_cancel (eh); +} + + +/** + * Notify all that listen on @a es of an event. + * + * @param cls database context to use + * @param es specification of the event to generate + * @param extra additional event data provided + * @param extra_size number of bytes in @a extra + */ +static void +postgres_event_notify (void *cls, + const struct GNUNET_DB_EventHeaderP *es, + const void *extra, + size_t extra_size) +{ + struct PostgresClosure *pg = cls; + + return GNUNET_PQ_event_notify (pg->conn, + es, + extra, + extra_size); +} + + +/** * Connect to the db if the connection does not exist yet. * * @param[in,out] pg the plugin-specific state @@ -399,6 +462,9 @@ libtaler_plugin_auditordb_postgres_init (void *cls) plugin->preflight = &postgres_preflight; plugin->drop_tables = &postgres_drop_tables; plugin->create_tables = &postgres_create_tables; + plugin->event_listen = &postgres_event_listen; + plugin->event_listen_cancel = &postgres_event_listen_cancel; + plugin->event_notify = &postgres_event_notify; plugin->start = &postgres_start; plugin->commit = &postgres_commit; plugin->rollback = &postgres_rollback; |