Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Endgame mode is always enabled, remove option.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 24 Oct 2019 12:33:16 +0000 (14:33 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 24 Oct 2019 20:39:07 +0000 (22:39 +0200)
examples/s4u/app-bittorrent/s4u-peer.cpp
teshsuite/msg/app-bittorrent/bittorrent-peer.c

index 360bb20..d3415ad 100644 (file)
@@ -22,7 +22,6 @@ constexpr int BLOCK_SIZE              = 16384;
 /** Number of blocks asked by each request */
 constexpr unsigned long BLOCKS_REQUESTED = 2UL;
 
-constexpr bool ENABLE_END_GAME_MODE = true;
 constexpr double SLEEP_DURATION     = 1.0;
 #define BITS_TO_BYTES(x) (((x) / 8 + (x) % 8) ? 1 : 0)
 
@@ -369,10 +368,6 @@ void Peer::handleMessage()
       XBT_DEBUG(" \t for piece %d (%d,%d)", message->piece, message->block_index,
                 message->block_index + message->block_length);
       xbt_assert(not remote_peer->choked_download);
-      xbt_assert(remote_peer->am_interested || ENABLE_END_GAME_MODE,
-                 "Can't received a piece if I'm not interested without end-game mode!"
-                 "piece (%d) bitfield (%u) remote bitfield (%u)",
-                 message->piece, bitfield_, remote_peer->bitfield);
       xbt_assert(not remote_peer->choked_download, "Can't received a piece if I'm choked !");
       xbt_assert((message->piece >= 0 && static_cast<unsigned int>(message->piece) < FILE_PIECES),
                  "Wrong piece received");
@@ -394,7 +389,6 @@ void Peer::handleMessage()
         }
       } else {
         XBT_DEBUG("However, we already have it");
-        xbt_assert(ENABLE_END_GAME_MODE, "Should not happen because we don't use end game mode !");
         requestNewPieceTo(remote_peer);
       }
       break;
@@ -444,8 +438,6 @@ int Peer::selectPieceToDownload(Connection* remote_peer)
 
   // end game mode
   if (countPieces(current_pieces) >= (FILE_PIECES - countPieces(bitfield_)) && isInterestedBy(remote_peer)) {
-    if (not ENABLE_END_GAME_MODE)
-      return -1;
     int nb_interesting_pieces = 0;
     // compute the number of interesting pieces
     for (unsigned int i = 0; i < FILE_PIECES; i++)
index f959e9c..e2eb994 100644 (file)
@@ -26,7 +26,6 @@ static const unsigned long int FILE_SIZE = FILE_PIECES * PIECES_BLOCKS * BLOCK_S
 /** Number of blocks asked by each request */
 #define BLOCKS_REQUESTED 2
 
-#define ENABLE_END_GAME_MODE 1
 #define SLEEP_DURATION 1
 
 int count_pieces(unsigned int bitfield)
@@ -390,10 +389,6 @@ void handle_message(peer_t peer, msg_task_t task)
       XBT_DEBUG(" \t for piece %d (%d,%d)", message->index, message->block_index,
                 message->block_index + message->block_length);
       xbt_assert(!remote_peer->choked_download);
-      xbt_assert(remote_peer->am_interested || ENABLE_END_GAME_MODE,
-                 "Can't received a piece if I'm not interested wihtout end-game mode!"
-                 "piece (%d) bitfield(%u) remote bitfield(%u)",
-                 message->index, peer->bitfield, remote_peer->bitfield);
       xbt_assert(remote_peer->choked_download != 1, "Can't received a piece if I'm choked !");
       xbt_assert((message->index >= 0 && message->index < FILE_PIECES), "Wrong piece received");
       // TODO: Execute à computation.
@@ -417,7 +412,6 @@ void handle_message(peer_t peer, msg_task_t task)
         }
       } else {
         XBT_DEBUG("However, we already have it");
-        xbt_assert(ENABLE_END_GAME_MODE, "Should not happen because we don't use end game mode !");
         request_new_piece_to_peer(peer, remote_peer);
       }
       break;
@@ -485,9 +479,6 @@ int select_piece_to_download(peer_t peer, connection_t remote_peer)
   // end game mode
   if (count_pieces(peer->current_pieces) >= (FILE_PIECES - count_pieces(peer->bitfield)) &&
       (is_interested(peer, remote_peer) != 0)) {
-#if ENABLE_END_GAME_MODE == 0
-    return -1;
-#endif
     int nb_interesting_pieces = 0;
     // compute the number of interesting pieces
     for (int i = 0; i < FILE_PIECES; i++) {