aboutsummaryrefslogtreecommitdiff
path: root/src/peerstore/plugin_peerstore_sqlite.c
diff options
context:
space:
mode:
authorOmar Tarabai <tarabai@devegypt.com>2014-05-07 14:14:38 +0000
committerOmar Tarabai <tarabai@devegypt.com>2014-05-07 14:14:38 +0000
commit36367311686410711f46fa3d82484a609c888acf (patch)
tree62a6afbe310a8479e18221d0606a715948adeb5b /src/peerstore/plugin_peerstore_sqlite.c
parent0778d7e951b20f42af01597ae41ba8d2d26857d0 (diff)
downloadgnunet-36367311686410711f46fa3d82484a609c888acf.tar.gz
gnunet-36367311686410711f46fa3d82484a609c888acf.zip
PEERSTORE api update
Diffstat (limited to 'src/peerstore/plugin_peerstore_sqlite.c')
-rw-r--r--src/peerstore/plugin_peerstore_sqlite.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/peerstore/plugin_peerstore_sqlite.c b/src/peerstore/plugin_peerstore_sqlite.c
index 41b6044b3..1695938bb 100644
--- a/src/peerstore/plugin_peerstore_sqlite.c
+++ b/src/peerstore/plugin_peerstore_sqlite.c
@@ -85,26 +85,26 @@ struct Plugin
85 * One key can store multiple values. 85 * One key can store multiple values.
86 * 86 *
87 * @param cls closure (internal context for the plugin) 87 * @param cls closure (internal context for the plugin)
88 * @param sub_system name of the GNUnet sub system responsible
89 * @param peer peer identity 88 * @param peer peer identity
89 * @param sub_system name of the GNUnet sub system responsible
90 * @param value value to be stored 90 * @param value value to be stored
91 * @param size size of value to be stored 91 * @param size size of value to be stored
92 * @return #GNUNET_OK on success, else #GNUNET_SYSERR 92 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
93 */ 93 */
94static int 94static int
95peerstore_sqlite_store_record (void *cls, 95peerstore_sqlite_store_record (void *cls,
96 const char *sub_system, 96 const struct GNUNET_PeerIdentity *peer,
97 const struct GNUNET_PeerIdentity *peer, 97 const char *sub_system,
98 const void *value, 98 const void *value,
99 size_t size) 99 size_t size)
100{ 100{
101 struct Plugin *plugin = cls; 101 struct Plugin *plugin = cls;
102 sqlite3_stmt *stmt = plugin->insert_peerstoredata; 102 sqlite3_stmt *stmt = plugin->insert_peerstoredata;
103 103
104 //FIXME: check if value exists with the same key first 104 //FIXME: check if value exists with the same key first
105 105
106 if(SQLITE_OK != sqlite3_bind_text(stmt, 1, sub_system, sizeof(sub_system), SQLITE_STATIC) 106 if(SQLITE_OK != sqlite3_bind_blob(stmt, 2, peer, sizeof(struct GNUNET_PeerIdentity), SQLITE_STATIC)
107 || SQLITE_OK != sqlite3_bind_blob(stmt, 2, peer, sizeof(struct GNUNET_PeerIdentity), SQLITE_STATIC) 107 || SQLITE_OK != sqlite3_bind_text(stmt, 1, sub_system, sizeof(sub_system), SQLITE_STATIC)
108 || SQLITE_OK != sqlite3_bind_blob(stmt, 3, value, size, SQLITE_STATIC)) 108 || SQLITE_OK != sqlite3_bind_blob(stmt, 3, value, size, SQLITE_STATIC))
109 LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 109 LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
110 "sqlite3_bind"); 110 "sqlite3_bind");
@@ -227,15 +227,15 @@ database_setup (struct Plugin *plugin)
227 227
228 sql_exec (plugin->dbh, 228 sql_exec (plugin->dbh,
229 "CREATE TABLE IF NOT EXISTS peerstoredata (\n" 229 "CREATE TABLE IF NOT EXISTS peerstoredata (\n"
230 " sub_system TEXT NOT NULL,\n"
231 " peer_id BLOB NOT NULL,\n" 230 " peer_id BLOB NOT NULL,\n"
231 " sub_system TEXT NOT NULL,\n"
232 " value BLOB NULL" 232 " value BLOB NULL"
233 ");"); 233 ");");
234 234
235 /* Prepare statements */ 235 /* Prepare statements */
236 236
237 sql_prepare (plugin->dbh, 237 sql_prepare (plugin->dbh,
238 "INSERT INTO peerstoredata (sub_system, peer_id, value) VALUES (?,?,?);", 238 "INSERT INTO peerstoredata (peer_id, sub_system, value) VALUES (?,?,?);",
239 &plugin->insert_peerstoredata); 239 &plugin->insert_peerstoredata);
240 240
241 return GNUNET_OK; 241 return GNUNET_OK;