/*
* This file is part of GNUnet
- * (C) 2013 Christian Grothoff (and other contributing authors)
+ * Copyright (C) 2013 GNUnet e.V.
*
* GNUnet is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
*
* You should have received a copy of the GNU General Public License
* along with GNUnet; see the file COPYING. If not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
/**
*
* @param cls closure (internal context for the plugin)
* @param now time to use as reference
- * @return number of records deleted
+ * @param cont continuation called with the number of records expired
+ * @param cont_cls continuation closure
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error and cont is not
+ * called
*/
static int
-peerstore_sqlite_expire_records (void *cls, struct GNUNET_TIME_Absolute now)
+peerstore_sqlite_expire_records (void *cls, struct GNUNET_TIME_Absolute now,
+ GNUNET_PEERSTORE_Continuation cont,
+ void *cont_cls)
{
struct Plugin *plugin = cls;
sqlite3_stmt *stmt = plugin->expire_peerstoredata;
{
LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"sqlite3_reset");
- return 0;
+ return GNUNET_SYSERR;
}
- return sqlite3_changes (plugin->dbh);
+ if (NULL != cont)
+ {
+ cont (cont_cls, sqlite3_changes (plugin->dbh));
+ }
+ return GNUNET_OK;
}
* @param sub_system name of sub system
* @param peer Peer identity (can be NULL)
* @param key entry key string (can be NULL)
- * @param iter function to call with the result
+ * @param iter function to call asynchronously with the results, terminated
+ * by a NULL result
* @param iter_cls closure for @a iter
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error and iter is not
+ * called
*/
static int
peerstore_sqlite_iterate_records (void *cls, const char *sub_system,
"sqlite3_reset");
err = 1;
}
- if (err)
- return GNUNET_SYSERR;
+ if (NULL != iter)
+ {
+ iter (iter_cls, NULL, err ? "sqlite error" : NULL);
+ }
return GNUNET_OK;
}
* @param size size of value to be stored
* @param expiry absolute time after which the record is (possibly) deleted
* @param options options related to the store operation
- * @return #GNUNET_OK on success, else #GNUNET_SYSERR
+ * @param cont continuation called when record is stored
+ * @param cont_cls continuation closure
+ * @return #GNUNET_OK on success, else #GNUNET_SYSERR and cont is not called
*/
static int
peerstore_sqlite_store_record (void *cls, const char *sub_system,
const struct GNUNET_PeerIdentity *peer,
const char *key, const void *value, size_t size,
struct GNUNET_TIME_Absolute expiry,
- enum GNUNET_PEERSTORE_StoreOption options)
+ enum GNUNET_PEERSTORE_StoreOption options,
+ GNUNET_PEERSTORE_Continuation cont,
+ void *cont_cls)
{
struct Plugin *plugin = cls;
sqlite3_stmt *stmt = plugin->insert_peerstoredata;
"sqlite3_reset");
return GNUNET_SYSERR;
}
+ if (NULL != cont)
+ {
+ cont (cont_cls, GNUNET_OK);
+ }
return GNUNET_OK;
}
sql_exec (plugin->dbh, "PRAGMA legacy_file_format=OFF");
sql_exec (plugin->dbh, "PRAGMA auto_vacuum=INCREMENTAL");
sql_exec (plugin->dbh, "PRAGMA encoding=\"UTF-8\"");
- sql_exec (plugin->dbh, "PRAGMA count_changes=OFF");
sql_exec (plugin->dbh, "PRAGMA page_size=4096");
sqlite3_busy_timeout (plugin->dbh, BUSY_TIMEOUT_MS);
/* Create tables */