2
This file is part of GNUnet
3
(C) 2004, 2005, 2006 Christian Grothoff (and other contributing authors)
5
GNUnet is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published
7
by the Free Software Foundation; either version 2, or (at your
8
option) any later version.
10
GNUnet is distributed in the hope that it will be useful, but
11
WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
General Public License for more details.
15
You should have received a copy of the GNU General Public License
16
along with GNUnet; see the file COPYING. If not, write to the
17
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
Boston, MA 02111-1307, USA.
22
* @file module/dstore.c
23
* @brief entries in local DHT
24
* @author Simo Viitanen, Christian Grothoff
29
#include "gnunet_blockstore.h"
31
#define DEBUG_DSTORE NO
33
static Dstore_ServiceAPI *dstore;
35
static CoreAPIForApplication *coreAPI;
38
* Lookup in the local datastore.
39
* @return total number of results found
42
dht_store_get (const HashCode512 * key,
43
unsigned int type, ResultHandler handler, void *cls)
45
return dstore->get (key, type, handler, cls);
49
* Store the given data in the local datastore.
52
dht_store_put (unsigned int type,
53
const HashCode512 * key,
54
cron_t discard_time, unsigned int size, const char *data)
56
if (discard_time < get_time ())
59
GE_LOG (coreAPI->ectx,
60
GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
61
"Content already expired (%llu < %llu), will not keep.\n",
62
discard_time, get_time ());
66
dstore->put (key, type, discard_time, size, data);
70
* Initialize dstore DHT component.
72
* @param capi the core API
73
* @return OK on success
76
init_dht_store (size_t max_size, CoreAPIForApplication * capi)
79
dstore = coreAPI->requestService ("dstore");
86
* Shutdown dstore DHT component.
88
* @return OK on success
93
coreAPI->releaseService (dstore);