Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
used unsigned long long to have more than 50 bits
[simgrid.git] / examples / msg / app-bittorrent / connection.h
index 0bfcde0..cd33620 100644 (file)
@@ -10,7 +10,7 @@
 /**  Contains the connection data of a peer. */
 typedef struct s_connection {
   int id;                       //Peer id
-  char *bitfield;               //Fields
+  unsigned int bitfield;        //Fields
   char *mailbox;
   int messages_count;
   double peer_speed;
@@ -20,7 +20,9 @@ typedef struct s_connection {
   unsigned int interested:1;      //Indicates if the peer is interested in one of our pieces
   unsigned int choked_upload:1;   //Indicates if the peer is choked for the current peer
   unsigned int choked_download:1; //Indicates if the peer has choked the current peer
-} s_connection_t, *connection_t;
+} s_connection_t;
+
+typedef s_connection_t *connection_t;
 
 /** @brief Build a new connection object from the peer id.
  *  @param id id of the peer
@@ -33,4 +35,5 @@ connection_t connection_new(int id);
 void connection_add_speed_value(connection_t connection, double speed);
 /** Frees a connection object */
 void connection_free(void *data);
+int connection_has_piece(connection_t connection, unsigned int piece);
 #endif                          /* BITTORRENT_CONNECTION_H_ */