Send only to IDs, not addresses.

Was not used anyway.
This commit is contained in:
Théophile Bastian 2016-11-26 19:21:13 +01:00
parent 86c91f7488
commit 619ea6969e
2 changed files with 7 additions and 36 deletions

View file

@ -83,33 +83,23 @@ void Protocol::sendBody(const Bytes& body, const u64& id) {
return sendBody(body, addrOfId(id));
}
void Protocol::sendEmpty(const SockAddr& to) {
void Protocol::sendEmpty(u64 to) {
sendBody(Bytes(), to);
}
void Protocol::sendEmpty(u64 to) {
sendEmpty(addrOfId(to));
}
void Protocol::sendIHU(const SockAddr& to, u64 id) {
void Protocol::sendIHU(u64 id) {
Bytes pck;
pck << csts::TLV_IHU << (u8) 8 << id;
sendBody(pck, to);
}
void Protocol::sendIHU(u64 id) {
sendIHU(addrOfId(id), id);
sendBody(pck, id);
}
void Protocol::sendNReq(const SockAddr& to) {
void Protocol::sendNReq(u64 to) {
Bytes pck;
pck << csts::TLV_NR << (u8) 0;
sendBody(pck, to);
}
void Protocol::sendNReq(u64 id) {
sendNReq(addrOfId(id));
}
void Protocol::sendNeighbours(const SockAddr& to,
const std::vector<Neighbour>& neigh) {
void Protocol::sendNeighbours(u64 to, const std::vector<Neighbour>& neigh) {
Bytes pck;
u8 len = neigh.size() * (8+16+2);
pck << csts::TLV_NEIGH << len;
@ -124,11 +114,8 @@ void Protocol::sendNeighbours(const SockAddr& to,
sendBody(pck, to);
}
void Protocol::sendNeighbours(u64 id, const std::vector<Neighbour>& neigh) {
sendNeighbours(addrOfId(id), neigh);
}
void Protocol::sendData(const SockAddr& to, const Bytes& data,
void Protocol::sendData(u64 to, const Bytes& data,
u32 seqno, u64 datId)
{
Bytes pck;
@ -138,20 +125,12 @@ void Protocol::sendData(const SockAddr& to, const Bytes& data,
<< data;
sendBody(pck, to);
}
void Protocol::sendData(u64 id, const Bytes& data, u32 seqno,
u64 datId)
{
sendData(addrOfId(id), data, seqno, datId);
}
void Protocol::sendIHave(const SockAddr& to, u64 datId, u32 seqno) {
void Protocol::sendIHave(u64 to, u64 datId, u32 seqno) {
Bytes pck;
pck << csts::TLV_IHAVE << (u8) 12 << seqno << datId;
sendBody(pck, to);
}
void Protocol::sendIHave(u64 id, u64 datId, u32 seqno) {
sendIHave(addrOfId(id), datId, seqno);
}
void Protocol::startPollNetwork() {
pollThread = std::thread([this] { this->pollNetwork(); });

View file

@ -44,28 +44,20 @@ class Protocol {
void sendBody(const Bytes& body, const u64& id);
/** Sends the given `body` (wrapped in headers) */
void sendEmpty(const SockAddr& to);
void sendEmpty(u64 to);
void sendIHU(const SockAddr& to, u64 id);
void sendIHU(u64 id);
/** Sends a IHU packet */
void sendNReq(const SockAddr& to);
void sendNReq(u64 id);
/** Sends a neighbour request packet */
void sendNeighbours(const SockAddr& to,
const std::vector<Neighbour>& neigh);
void sendNeighbours(u64 id,
const std::vector<Neighbour>& neigh);
/** Sends a neighbours list packet */
void sendData(const SockAddr& to, const Bytes& data,
u32 seqno, u64 datId);
void sendData(u64 id, const Bytes& data, u32 seqno, u64 datId);
void sendIHave(const SockAddr& to, u64 datId, u32 seqno);
void sendIHave(u64 id, u64 datId, u32 seqno);
/** Sends a IHave packet for `datId` */