getting aggregator structure laid out for #4141

This commit is contained in:
Christian Grothoff 2016-01-25 15:08:29 +01:00
parent 57c1d2318f
commit bd3700e608
2 changed files with 86 additions and 9 deletions

View File

@ -618,6 +618,19 @@ typedef void
const struct TALER_Amount *transfer_value); const struct TALER_Amount *transfer_value);
/**
* Callback with data about a prepared transaction.
*
* @param cls closure
* @param buf transaction data that was persisted, NULL on error
* @param buf_size number of bytes in @a buf, 0 on error
*/
typedef void
(*TALER_MINTDB_WirePreparationCallback) (void *cls,
const char *buf,
size_t buf_size);
/** /**
* @brief The plugin API, returned from the plugin's "init" function. * @brief The plugin API, returned from the plugin's "init" function.
* The argument given to "init" is simply a configuration handle. * The argument given to "init" is simply a configuration handle.
@ -1308,7 +1321,66 @@ struct TALER_MINTDB_Plugin
const struct TALER_Amount *transfer_value); const struct TALER_Amount *transfer_value);
/**
* Function called to insert wire transfer commit data into the DB.
*
* @param cls closure
* @param session database connection
* @param type type fo the wire transfer (i.e. "sepa")
* @param buf buffer with wire transfer preparation data
* @param buf_size number of bytes in @a buf
* @return #GNUNET_OK on success, #GNUNET_SYSERR on DB errors
*/
int
(*wire_prepare_data_insert)(void *cls,
struct TALER_MINTDB_Session *session,
const char *type,
const char *buf,
size_t buf_size);
/**
* Function called to mark wire transfer commit data as finished.
*
* @param cls closure
* @param session database connection
* @param type type fo the wire transfer (i.e. "sepa")
* @param buf buffer with wire transfer preparation data
* @param buf_size number of bytes in @a buf
* @return #GNUNET_OK on success, #GNUNET_SYSERR on DB errors
*/
int
(*wire_prepare_data_mark_finished)(void *cls,
struct TALER_MINTDB_Session *session,
const char *type,
const char *buf,
size_t buf_size);
/**
* Function called to iterate over unfinished wire transfer
* preparation data. Fetches at most one item.
*
* @param cls closure
* @param session database connection
* @param type type fo the wire transfer (i.e. "sepa")
* @param cb function to call for ONE unfinished item
* @param cb_cls closure for @a cb
* @return #GNUNET_OK on success,
* #GNUNET_NO if there are no entries,
* #GNUNET_SYSERR on DB errors
*/
int
(*wire_prepare_data_iterate)(void *cls,
struct TALER_MINTDB_Session *session,
const char *type,
TALER_MINTDB_WirePreparationCallback cb,
void *cb_cls);
}; };
#endif /* _NEURO_MINT_DB_H */ #endif /* _TALER_MINT_DB_H */

View File

@ -220,9 +220,11 @@ run (void *cls,
return; return;
} }
/* FIXME: finish aggregate computation */ /* FIXME: finish aggregate computation */
/* FIXME: insert pre-commit data for transaction into DB */ /* wire_plugin->prepare_wire_transfer () -- ASYNC! */
/* FIXME: mark transactions selected for aggregate as finished */ /* db_plugin->wire_prepare_data_insert () -- transactional! */
/* db_plugin->XXX () -- mark transactions selected for aggregate as finished */
/* then finally: commit! */
if (GNUNET_OK != if (GNUNET_OK !=
db_plugin->commit (db_plugin->cls, db_plugin->commit (db_plugin->cls,
session)) session))
@ -231,12 +233,15 @@ run (void *cls,
"Failed to commit database transaction!\n"); "Failed to commit database transaction!\n");
} }
/* FIXME: run 2nd transaction: /* While possible, run 2nd type of transaction:
- begin db_plugin->start()
- select pre-commit data from DB - select pre-commit data from DB:
- execute wire transfer db_plugin->wire_prepare_data_iterate ()
- insert aggregation tracking information into DB - execute wire transfer (successfully!)
- commit! wire_plugin->execute_wire_transfer() # ASYNC!
db_plugin->wire_prepare_data_mark_finished ()
db_plugin->insert_aggregation_tracking ()
db_plugin->commit()
*/ */