void TrackerClient::timerEvent(QTimerEvent *event) { if (event->timerId() == requestIntervalTimer) { fetchPeerList(); } else { QObject::timerEvent(event); } }
void TrackerClient::timerEvent(QTimerEvent *event) { if (event->timerId() == requestIntervalTimer) { if (http.state() == QHttp::Unconnected) fetchPeerList(); } else { QObject::timerEvent(event); } }
void TrackerClient::start(const MetaInfo &info) { metaInfo = info; QTimer::singleShot(0, this, SLOT(fetchPeerList())); if (metaInfo.fileForm() == MetaInfo::SingleFileForm) { length = metaInfo.singleFile().length; } else { QList<MetaInfoMultiFile> files = metaInfo.multiFiles(); for (int i = 0; i < files.size(); ++i) length += files.at(i).length; } }
void P2pNode::connectPeers() { if (!m_cfg.getExclusiveNodes().empty()) { connectPeerList(m_cfg.getExclusiveNodes()); return; } // if white peer list is empty, get peers from seeds if (m_peerlist.get_white_peers_count() == 0 && !m_cfg.getSeedNodes().empty()) { auto seedNodes = m_cfg.getSeedNodes(); std::random_shuffle(seedNodes.begin(), seedNodes.end()); for (const auto& seed : seedNodes) { auto conn = tryToConnectPeer(seed); if (conn != nullptr && fetchPeerList(std::move(conn))) { break; } } } connectPeerList(m_cfg.getPriorityNodes()); const size_t totalExpectedConnectionsCount = m_cfg.getExpectedOutgoingConnectionsCount(); const size_t expectedWhiteConnections = (totalExpectedConnectionsCount * m_cfg.getWhiteListConnectionsPercent()) / 100; const size_t outgoingConnections = getOutgoingConnectionsCount(); if (outgoingConnections < totalExpectedConnectionsCount) { if (outgoingConnections < expectedWhiteConnections) { //start from white list makeExpectedConnectionsCount(m_peerlist.getWhite(), expectedWhiteConnections); //and then do grey list makeExpectedConnectionsCount(m_peerlist.getGray(), totalExpectedConnectionsCount); } else { //start from grey list makeExpectedConnectionsCount(m_peerlist.getGray(), totalExpectedConnectionsCount); //and then do white list makeExpectedConnectionsCount(m_peerlist.getWhite(), totalExpectedConnectionsCount); } } }
void TrackerClient::stop() { lastTrackerRequest = true; http.abort(); fetchPeerList(); }
void TrackerClient::startSeeding() { firstSeeding = true; fetchPeerList(); }