+ {
+ off = (off + 1) % total;
+ GNUNET_snprintf (scratch, sizeof (scratch),
+ "SELECT value,expire FROM ds090 WHERE key=? AND type=? AND expire >= ? LIMIT 1 OFFSET %u",
+ off);
+ if (sq_prepare (plugin->dbh, scratch, &stmt) != SQLITE_OK)
+ {
+ LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ "sq_prepare");
+ return cnt;
+ }
+ if ((SQLITE_OK !=
+ sqlite3_bind_blob (stmt, 1, key, sizeof (struct GNUNET_HashCode),
+ SQLITE_TRANSIENT)) ||
+ (SQLITE_OK != sqlite3_bind_int (stmt, 2, type)) ||
+ (SQLITE_OK != sqlite3_bind_int64 (stmt, 3, now.abs_value)))
+ {
+ LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ "sqlite3_bind_xxx");
+ sqlite3_finalize (stmt);
+ return cnt;
+ }
+ if (sqlite3_step (stmt) != SQLITE_ROW)
+ break;
+ size = sqlite3_column_bytes (stmt, 0);
+ dat = sqlite3_column_blob (stmt, 0);
+ exp.abs_value = sqlite3_column_int64 (stmt, 1);
+ ntime = (int64_t) exp.abs_value;
+ if (ntime == INT64_MAX)
+ exp = GNUNET_TIME_UNIT_FOREVER_ABS;
+ cnt++;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Found %u-byte result when processing `%s' for key `%4s'\n",
+ (unsigned int) size, "GET", GNUNET_h2s (key));
+ if (GNUNET_OK != iter (iter_cls, exp, key, size, dat, type))