bool EndpointPool::addEndpoint(Endpoint endpoint, int64_t penalty) { if (!endpoint.isRoutable()) return false; if (endpoint.getIP() == _localhost.getIP()) return false; endpoint.setTime(max((int64_t)0, (int64_t)endpoint.getTime() - penalty)); Endpoint found = endpoint; query("INSERT OR REPLACE INTO Endpoints VALUES (?, ?, ?, ?)", (int64_t)endpoint.getIP(), (int64_t)endpoint.getPort(), (int64_t)endpoint.getTime(), 0); return true; }
void EndpointPool::setLastTry(const Endpoint& ep) { int64_t now = GetAdjustedTime(); query("UPDATE Endpoints SET lasttry = ? WHERE ip = ? AND port = ?", now, (int64_t)ep.getIP(), ep.getPort()); }
void EndpointPool::currentlyConnected(const Endpoint& ep) { int64_t now = GetAdjustedTime(); query("UPDATE Endpoints SET time = ? WHERE ip = ? AND port = ?", now, (int64_t)ep.getIP(), ep.getPort()); }