void ProcessorGraph::clearConnections() { for (int i = 0; i < getNumConnections(); i++) { const Connection* connection = getConnection(i); if (connection->destNodeId == RESAMPLING_NODE_ID || connection->destNodeId == OUTPUT_NODE_ID) { ; // leave it } else { removeConnection(i); } } for (int i = 0; i < getNumNodes(); i++) { Node* node = getNode(i); if (node->nodeId != OUTPUT_NODE_ID) { GenericProcessor* p =(GenericProcessor*) node->getProcessor(); p->resetConnections(); } } }
enum BlockSource ClientModel::getBlockSource() const { if (fReindex) return BLOCK_SOURCE_REINDEX; else if (fImporting) return BLOCK_SOURCE_DISK; else if (getNumConnections() > 0) return BLOCK_SOURCE_NETWORK; return BLOCK_SOURCE_NONE; }
void Acceptor::drainConnections(double pctToDrain) { if (downstreamConnectionManager_) { LOG(INFO) << "Draining " << pctToDrain * 100 << "% of " << getNumConnections() << " connections from Acceptor=" << this << " in thread " << base_; assert(base_->isInEventBaseThread()); downstreamConnectionManager_-> drainConnections(pctToDrain, gracefulShutdownTimeout_); } }
enum BlockSource ClientModel::getBlockSource() const { if (m_node.getReindex()) return BlockSource::REINDEX; else if (m_node.getImporting()) return BlockSource::DISK; else if (getNumConnections() > 0) return BlockSource::NETWORK; return BlockSource::NONE; }
void Acceptor::dropConnections(double pctToDrop) { base_->runInEventBaseThread([&, pctToDrop] { if (downstreamConnectionManager_) { LOG(INFO) << "Dropping " << pctToDrop * 100 << "% of " << getNumConnections() << " connections from Acceptor=" << this << " in thread " << base_; assert(base_->isInEventBaseThread()); forceShutdownInProgress_ = true; downstreamConnectionManager_->dropConnections(pctToDrop); } }); }
void ClientModel::update() { int newNumConnections = getNumConnections(); int newNumBlocks = getNumBlocks(); QString newStatusBar = getStatusBarWarnings(); if(cachedNumConnections != newNumConnections) emit numConnectionsChanged(newNumConnections); if(cachedNumBlocks != newNumBlocks || cachedStatusBar != newStatusBar) emit numBlocksChanged(newNumBlocks); cachedNumConnections = newNumConnections; cachedNumBlocks = newNumBlocks; cachedStatusBar = newStatusBar; }
void ClientModel::update() { int newNumConnections = getNumConnections(); int newNumBlocks = getNumBlocks(); if(cachedNumConnections != newNumConnections) emit numConnectionsChanged(newNumConnections); if(cachedNumBlocks != newNumBlocks) emit numBlocksChanged(newNumBlocks); cachedNumConnections = newNumConnections; cachedNumBlocks = newNumBlocks; // Only need to update if solo mining. When pool mining, stats are pushed. if (miningType == SoloMining) { int newHashrate = getHashrate(); if (cachedHashrate != newHashrate) emit miningChanged(miningStarted, newHashrate); cachedHashrate = newHashrate; } }
void ConnectionManager::removeConnection(ManagedConnection* connection) { if (connection->getConnectionManager() == this) { connection->cancelTimeout(); connection->setConnectionManager(nullptr); // Un-link the connection from our list, being careful to keep the iterator // that we're using for idle shedding valid auto it = conns_.iterator_to(*connection); if (it == idleIterator_) { ++idleIterator_; } conns_.erase(it); if (callback_) { callback_->onConnectionRemoved(*this); if (getNumConnections() == 0) { callback_->onEmpty(*this); } } } }
void ClientModel::update() { int newNumConnections = getNumConnections(); int newNumBlocks = getNumBlocks(); QString newStatusBar = getStatusBarWarnings(); if(cachedNumConnections != newNumConnections) emit numConnectionsChanged(newNumConnections); if(cachedNumBlocks != newNumBlocks || cachedStatusBar != newStatusBar) { // Simply emit a numBlocksChanged for now in case the status message changes, // so that the view updates the status bar. // TODO: It should send a notification. // (However, this might generate looped notifications and needs to be thought through and tested carefully) // error(tr("Network Alert"), newStatusBar); emit numBlocksChanged(newNumBlocks); } cachedNumConnections = newNumConnections; cachedNumBlocks = newNumBlocks; cachedStatusBar = newStatusBar; }