-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
class Peer {
int id;
double deadline;
+ simgrid::xbt::random::XbtRandom random;
simgrid::s4u::Mailbox* mailbox_;
std::unordered_map<int, Connection> connected_peers;
std::set<Connection*> active_peers; // active peers list
simgrid::s4u::CommPtr comm_received = nullptr; // current comm
Message* message = nullptr; // current message being received
+
public:
explicit Peer(std::vector<std::string> args);
Peer(const Peer&) = delete;
void updateChokedPeers();
bool hasNotPiece(unsigned int piece) const { return not(bitfield_ & 1U << piece); }
+ bool remotePeerHasMissingPiece(const Connection* remote_peer, unsigned int piece)
+ {
+ return hasNotPiece(piece) && remote_peer->hasPiece(piece);
+ }
bool hasCompletedPiece(unsigned int piece);
unsigned int countPieces(unsigned int bitfield);
/** Check that a piece is not currently being download by the peer. */