trying to fix #3576
[oweals/gnunet.git] / src / fs / fs.h
index cd39522bc8998cad23ae8bba66d206ddcf4fac9c..ae6ca489a074cce8c326090bc78e5421292c14a8 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Christian Grothoff (and other contributing authors)
+     (C) 2003--2012 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -37,7 +37,7 @@
 /**
  * Size of the individual blocks used for file-sharing.
  */
-#define DBLOCK_SIZE (32*1024)
+#define DBLOCK_SIZE (32 * 1024)
 
 /**
  * Blocksize to use when hashing files for indexing (blocksize for IO,
@@ -55,12 +55,12 @@ struct ContentHashKey
   /**
    * Hash of the original content, used for encryption.
    */
-  GNUNET_HashCode key;
+  struct GNUNET_HashCode key;
 
   /**
    * Hash of the encrypted content, used for querying.
    */
-  GNUNET_HashCode query;
+  struct GNUNET_HashCode query;
 };
 
 
@@ -83,7 +83,7 @@ struct IndexStartMessage
 {
 
   /**
-   * Message type will be GNUNET_MESSAGE_TYPE_FS_INDEX_START.
+   * Message type will be #GNUNET_MESSAGE_TYPE_FS_INDEX_START.
    */
   struct GNUNET_MessageHeader header;
 
@@ -112,7 +112,7 @@ struct IndexStartMessage
   /**
    * Hash of the file that we would like to index.
    */
-  GNUNET_HashCode file_id;
+  struct GNUNET_HashCode file_id;
 
   /* this is followed by a 0-terminated
    * filename of a file with the hash
@@ -129,7 +129,7 @@ struct IndexInfoMessage
 {
   /**
    * Message type will be
-   * GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_ENTRY.
+   * #GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_ENTRY.
    */
   struct GNUNET_MessageHeader header;
 
@@ -141,7 +141,7 @@ struct IndexInfoMessage
   /**
    * Hash of the indexed file.
    */
-  GNUNET_HashCode file_id;
+  struct GNUNET_HashCode file_id;
 
   /* this is followed by a 0-terminated
    * filename of a file with the hash
@@ -161,8 +161,7 @@ struct UnindexMessage
 {
 
   /**
-   * Message type will be
-   * GNUNET_MESSAGE_TYPE_FS_UNINDEX.
+   * Message type will be #GNUNET_MESSAGE_TYPE_FS_UNINDEX.
    */
   struct GNUNET_MessageHeader header;
 
@@ -174,7 +173,7 @@ struct UnindexMessage
   /**
    * Hash of the file that we will unindex.
    */
-  GNUNET_HashCode file_id;
+  struct GNUNET_HashCode file_id;
 
 };
 
@@ -206,8 +205,7 @@ struct SearchMessage
 {
 
   /**
-   * Message type will be
-   * GNUNET_MESSAGE_TYPE_FS_START_SEARCH.
+   * Message type will be #GNUNET_MESSAGE_TYPE_FS_START_SEARCH.
    */
   struct GNUNET_MessageHeader header;
 
@@ -240,26 +238,21 @@ struct SearchMessage
    * nevertheless, we should probably not use it for a DHT-lookup
    * or similar blunt actions in order to avoid exposing ourselves).
    * <p>
-   * If the request is for an SBLOCK, this is the identity of the
-   * pseudonym to which the SBLOCK belongs.
-   * <p>
-   * If the request is for a KBLOCK, "target" must be all zeros.
+   * Otherwise, "target" must be all zeros.
    */
-  GNUNET_HashCode target;
+  struct GNUNET_PeerIdentity target;
 
   /**
-   * Hash of the keyword (aka query) for KBLOCKs; Hash of
-   * the CHK-encoded block for DBLOCKS and IBLOCKS (aka query)
-   * and hash of the identifier XORed with the target for
-   * SBLOCKS (aka query).
+   * Hash of the public key for UBLOCKs; Hash of
+   * the CHK-encoded block for DBLOCKS and IBLOCKS.
    */
-  GNUNET_HashCode query;
+  struct GNUNET_HashCode query;
 
   /* this is followed by the hash codes of already-known
    * results (which should hence be excluded from what
    * the service returns); naturally, this only applies
-   * to queries that can have multiple results, such as
-   * those for KBLOCKS (KSK) and SBLOCKS (SKS) */
+   * to queries that can have multiple results (UBLOCKS).
+   */
 };
 
 
@@ -267,13 +260,41 @@ struct SearchMessage
  * Response from FS service with a result for a previous FS search.
  * Note that queries for DBLOCKS and IBLOCKS that have received a
  * single response are considered done.  This message is transmitted
- * between peers as well as between the service and a client.
+ * between peers.
  */
 struct PutMessage
 {
 
   /**
-   * Message type will be GNUNET_MESSAGE_TYPE_FS_PUT.
+   * Message type will be #GNUNET_MESSAGE_TYPE_FS_PUT.
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * Type of the block (in big endian).  Should never be zero.
+   */
+  uint32_t type GNUNET_PACKED;
+
+  /**
+   * When does this result expire?
+   */
+  struct GNUNET_TIME_AbsoluteNBO expiration;
+
+  /* this is followed by the actual encrypted content */
+
+};
+
+/**
+ * Response from FS service with a result for a previous FS search.
+ * Note that queries for DBLOCKS and IBLOCKS that have received a
+ * single response are considered done.  This message is transmitted
+ * between the service and a client.
+ */
+struct ClientPutMessage
+{
+
+  /**
+   * Message type will be #GNUNET_MESSAGE_TYPE_FS_PUT.
    */
   struct GNUNET_MessageHeader header;
 
@@ -287,6 +308,24 @@ struct PutMessage
    */
   struct GNUNET_TIME_AbsoluteNBO expiration;
 
+  /**
+   * When was the last time we've tried to download this block?
+   * (FOREVER if unknown/not relevant)
+   */
+  struct GNUNET_TIME_AbsoluteNBO last_transmission;
+
+  /**
+   * How often did we transmit this query before getting an
+   * answer (estimate).
+   */
+  uint32_t num_transmissions;
+
+  /**
+   * How much respect did we offer (in total) before getting an
+   * answer (estimate).
+   */
+  uint32_t respect_offered;
+
   /* this is followed by the actual encrypted content */
 
 };