aboutsummaryrefslogtreecommitdiff
path: root/src/peerstore/plugin_peerstore_sqlite.c
diff options
context:
space:
mode:
authorOmar Tarabai <tarabai@devegypt.com>2014-05-14 17:06:27 +0000
committerOmar Tarabai <tarabai@devegypt.com>2014-05-14 17:06:27 +0000
commit3fd47482d18b111b1dd407258d1eb388df56c21e (patch)
treec58fa83178682ee8abcf01884150a1e04cb262a8 /src/peerstore/plugin_peerstore_sqlite.c
parent1eef3106cb6ed367eeaec6c35b2dcc76ef314db6 (diff)
downloadgnunet-3fd47482d18b111b1dd407258d1eb388df56c21e.tar.gz
gnunet-3fd47482d18b111b1dd407258d1eb388df56c21e.zip
added record expiry to sqlite
Diffstat (limited to 'src/peerstore/plugin_peerstore_sqlite.c')
-rw-r--r--src/peerstore/plugin_peerstore_sqlite.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/peerstore/plugin_peerstore_sqlite.c b/src/peerstore/plugin_peerstore_sqlite.c
index 10ab17650..c44914f43 100644
--- a/src/peerstore/plugin_peerstore_sqlite.c
+++ b/src/peerstore/plugin_peerstore_sqlite.c
@@ -208,7 +208,8 @@ peerstore_sqlite_store_record(void *cls,
208 const struct GNUNET_PeerIdentity *peer, 208 const struct GNUNET_PeerIdentity *peer,
209 const char *key, 209 const char *key,
210 const void *value, 210 const void *value,
211 size_t size) 211 size_t size,
212 struct GNUNET_TIME_Absolute expiry)
212{ 213{
213 struct Plugin *plugin = cls; 214 struct Plugin *plugin = cls;
214 sqlite3_stmt *stmt = plugin->insert_peerstoredata; 215 sqlite3_stmt *stmt = plugin->insert_peerstoredata;
@@ -218,7 +219,8 @@ peerstore_sqlite_store_record(void *cls,
218 if(SQLITE_OK != sqlite3_bind_text(stmt, 1, sub_system, strlen(sub_system) + 1, SQLITE_STATIC) 219 if(SQLITE_OK != sqlite3_bind_text(stmt, 1, sub_system, strlen(sub_system) + 1, SQLITE_STATIC)
219 || SQLITE_OK != sqlite3_bind_blob(stmt, 2, peer, sizeof(struct GNUNET_PeerIdentity), SQLITE_STATIC) 220 || SQLITE_OK != sqlite3_bind_blob(stmt, 2, peer, sizeof(struct GNUNET_PeerIdentity), SQLITE_STATIC)
220 || SQLITE_OK != sqlite3_bind_text(stmt, 3, key, strlen(key) + 1, SQLITE_STATIC) 221 || SQLITE_OK != sqlite3_bind_text(stmt, 3, key, strlen(key) + 1, SQLITE_STATIC)
221 || SQLITE_OK != sqlite3_bind_blob(stmt, 4, value, size, SQLITE_STATIC)) 222 || SQLITE_OK != sqlite3_bind_blob(stmt, 4, value, size, SQLITE_STATIC)
223 || SQLITE_OK != sqlite3_bind_int64(stmt, 5, (sqlite3_int64)expiry.abs_value_us))
222 LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 224 LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
223 "sqlite3_bind"); 225 "sqlite3_bind");
224 else if (SQLITE_DONE != sqlite3_step (stmt)) 226 else if (SQLITE_DONE != sqlite3_step (stmt))
@@ -343,30 +345,31 @@ database_setup (struct Plugin *plugin)
343 " sub_system TEXT NOT NULL,\n" 345 " sub_system TEXT NOT NULL,\n"
344 " peer_id BLOB NOT NULL,\n" 346 " peer_id BLOB NOT NULL,\n"
345 " key TEXT NOT NULL,\n" 347 " key TEXT NOT NULL,\n"
346 " value BLOB NULL" 348 " value BLOB NULL,\n"
349 " expiry INTEGER NOT NULL"
347 ");"); 350 ");");
348 351
349 /* Prepare statements */ 352 /* Prepare statements */
350 353
351 sql_prepare (plugin->dbh, 354 sql_prepare (plugin->dbh,
352 "INSERT INTO peerstoredata (sub_system, peer_id, key, value) VALUES (?,?,?,?);", 355 "INSERT INTO peerstoredata (sub_system, peer_id, key, value, expiry) VALUES (?,?,?,?,?);",
353 &plugin->insert_peerstoredata); 356 &plugin->insert_peerstoredata);
354 sql_prepare(plugin->dbh, 357 sql_prepare(plugin->dbh,
355 "SELECT peer_id, sub_system, value FROM peerstoredata" 358 "SELECT * FROM peerstoredata"
356 " WHERE sub_system = ?", 359 " WHERE sub_system = ?",
357 &plugin->select_peerstoredata); 360 &plugin->select_peerstoredata);
358 sql_prepare(plugin->dbh, 361 sql_prepare(plugin->dbh,
359 "SELECT peer_id, sub_system, value FROM peerstoredata" 362 "SELECT * FROM peerstoredata"
360 " WHERE sub_system = ?" 363 " WHERE sub_system = ?"
361 " AND peer_id = ?", 364 " AND peer_id = ?",
362 &plugin->select_peerstoredata_by_pid); 365 &plugin->select_peerstoredata_by_pid);
363 sql_prepare(plugin->dbh, 366 sql_prepare(plugin->dbh,
364 "SELECT peer_id, sub_system, value FROM peerstoredata" 367 "SELECT * FROM peerstoredata"
365 " WHERE sub_system = ?" 368 " WHERE sub_system = ?"
366 " AND key = ?", 369 " AND key = ?",
367 &plugin->select_peerstoredata_by_key); 370 &plugin->select_peerstoredata_by_key);
368 sql_prepare(plugin->dbh, 371 sql_prepare(plugin->dbh,
369 "SELECT peer_id, sub_system, value FROM peerstoredata" 372 "SELECT * FROM peerstoredata"
370 " WHERE sub_system = ?" 373 " WHERE sub_system = ?"
371 " AND peer_id = ?" 374 " AND peer_id = ?"
372 " AND key = ?", 375 " AND key = ?",