1 /* Copyright (c) 2012-2014, 2017. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #ifndef BITTORRENT_TRACKER_HPP_
8 #define BITTORRENT_TRACKER_HPP_
10 #include "s4u_bittorrent.hpp"
14 int peer_id; // peer id
15 simgrid::s4u::MailboxPtr return_mailbox;
16 int uploaded; // how much the peer has already uploaded
17 int downloaded; // how much the peer has downloaded
18 int left; // how much the peer has left
20 explicit TrackerQuery(int peer_id, simgrid::s4u::MailboxPtr return_mailbox, int uploaded, int downloaded, int left)
21 : peer_id(peer_id), return_mailbox(return_mailbox), uploaded(uploaded), downloaded(downloaded), left(left){};
22 ~TrackerQuery() = default;
23 int getPeerId() { return peer_id; }
24 simgrid::s4u::MailboxPtr getReturnMailbox() { return return_mailbox; }
28 int interval; // how often the peer should contact the tracker (unused for now)
29 std::set<int>* peers; // the peer list the peer has asked for.
31 explicit TrackerAnswer(int interval) : interval(interval) { peers = new std::set<int>; }
32 ~TrackerAnswer() { delete peers; };
33 void addPeer(int peer) { peers->insert(peer); }
34 std::set<int>* getPeers() { return peers; }
40 simgrid::s4u::MailboxPtr mailbox;
41 std::set<int> known_peers;
44 explicit Tracker(std::vector<std::string> args);
48 #endif /* BITTORRENT_TRACKER_HPP */