Exemplo n.º 1
0
void Contact::add_failure(const std::string& node, time_t time) {
    NetworkContact* c = contact_rec_for(node);
    if (c == nullptr) {
        ensure_rec_for(node);
        c = contact_rec_for(node);
        if (c == nullptr) {
            // Unable to add node in add_connect.
            return;
        }
    }
    c->AddFailure(time);
}
Exemplo n.º 2
0
void Contact::add_connect(const std::string& node, time_t time, uint32_t bytes_sent, uint32_t bytes_received) {
    NetworkContact* c = contact_rec_for(node);
    if (c == nullptr) {
        ensure_rec_for(node);
        c = contact_rec_for(node);
        if (c == nullptr) {
            // Unable to add node in add_connect.
            return;
        }
    }
    c->AddConnect(time, bytes_sent, bytes_received);
}
Exemplo n.º 3
0
void Contact::ensure_rec_for(const std::string& node) {
    const auto* current = contact_rec_for(node);
    if (current == nullptr) {
        NetworkContact r(node);
        contacts_.emplace_back(r);
    }
}
Exemplo n.º 4
0
void Contact::add_failure(int node, time_t time) {
  net_contact_rec* c = contact_rec_for(node);
  if (c == nullptr) {
    // TODO(rushfan): Add support for creating new contact records.
    return;
  }

  add_contact(c, time);
  c->numfails++;
}
Exemplo n.º 5
0
void Contact::add_connect(int node, time_t time, uint32_t bytes_sent, uint32_t bytes_received) {
  net_contact_rec* c = contact_rec_for(node);
  if (c == nullptr) {
    // TODO(rushfan): Add support for creating new contact records.
    return;
  }
  add_contact(c, time);

  uint32_t time32 = static_cast<uint32_t>(time);
  if (bytes_sent > 0) {
    c->lastcontactsent = time32;
    c->bytes_waiting = 0;
    c->bytes_sent += bytes_sent;
  }
  c->bytes_received += bytes_received;
}