static void addInTree(AstNode* nodep, bool linkable) { #ifndef VL_LEAK_CHECKS if (!linkable) return; // save some time, else the map will get huge! #endif NodeMap::iterator iter = s_nodes.find(nodep); if (iter == s_nodes.end()) { #ifdef VL_LEAK_CHECKS nodep->v3fatalSrc("AstNode is in tree, but not allocated\n"); #endif } else { if (!(iter->second & FLAG_ALLOCATED)) { #ifdef VL_LEAK_CHECKS nodep->v3fatalSrc("AstNode is in tree, but not allocated\n"); #endif } if (iter->second & FLAG_IN_TREE) { nodep->v3fatalSrc("AstNode is already in tree at another location\n"); } } int or_flags = FLAG_IN_TREE | (linkable?FLAG_LINKABLE:0); if (iter == s_nodes.end()) { s_nodes.insert(make_pair(nodep,or_flags)); } else { iter->second |= or_flags; } }
void handleNodeStatus(const ReceivedDataStructure<protocol::NodeStatus>& msg) { if (!needToQuery(msg.getSrcNodeID())) { return; } NodeData* data = node_map_.access(msg.getSrcNodeID()); if (data == NULL) { trace(TraceDiscoveryNewNodeFound, msg.getSrcNodeID().get()); data = node_map_.insert(msg.getSrcNodeID(), NodeData()); if (data == NULL) { getNode().registerInternalFailure("NodeDiscoverer OOM"); return; } } UAVCAN_ASSERT(data != NULL); if (msg.uptime_sec < data->last_seen_uptime) { trace(TraceDiscoveryNodeRestartDetected, msg.getSrcNodeID().get()); data->num_get_node_info_attempts = 0; } data->last_seen_uptime = msg.uptime_sec; if (!isRunning()) { startPeriodic(MonotonicDuration::fromMSec(TimerPollIntervalMs)); trace(TraceDiscoveryTimerStart, getPeriod().toUSec()); } }
void CKadHandler::HandleNodeRes(const CVariant& NodeRes, CKadNode* pNode, CComChannel* pChannel) { if(GetParent<CKademlia>()->Cfg()->GetBool("DebugRT")) LogLine(LOG_DEBUG, L"Recived 'Node Response' from %s", pNode->GetID().ToHex().c_str()); CVariant List = NodeRes["LIST"]; if(List.Count() > (uint32)GetParent<CKademlia>()->Cfg()->GetInt("NodeReqCount")) throw CException(LOG_ERROR, L"Node returned more nodes than requested (spam)"); SKadData* pData = pChannel->GetData<SKadData>(); // Note: if pData->pLookup is NULL this was just a bootstrap request NodeMap Nodes; for(uint32 i = 0; i<List.Count(); i++) { CPointer<CKadNode> pNewNode = new CKadNode(GetParent<CKademlia>()->Root()); pNewNode->Load(List.At(i)); if(GetParent<CKademlia>()->Root()->AddNode(pNewNode) && pData->pLookup) { CUInt128 uDistance = pData->pLookup->GetID() ^ pNewNode->GetID(); Nodes.insert(NodeMap::value_type(uDistance, pNewNode)); } } if(pData->pLookup) GetParent<CKademlia>()->Manager()->AddNodes(pData->pLookup, pNode, pChannel, Nodes); }
static void addNewed(const AstNode* nodep) { // Called by operator new on any node - only if VL_LEAK_CHECKS if (debug()) cout<<"-nodeNew: "<<(void*)(nodep)<<endl; NodeMap::iterator iter = s_nodes.find(nodep); if (iter!=s_nodes.end() || (iter->second & FLAG_ALLOCATED)) { ((AstNode*)(nodep))->v3fatalSrc("Newing AstNode object that is already allocated\n"); } if (iter == s_nodes.end()) { s_nodes.insert(make_pair(nodep,FLAG_ALLOCATED)); } }
std::pair<long, float> AntipoleInternalNode::visitNode(const std::vector<float>& image, float, NodeMap& node_map) const { node_map.insert(std::make_pair(HelperFunctions::distance2(image, left->getCenter()) - left->getRadius(), left)); node_map.insert(std::make_pair(HelperFunctions::distance2(image, right->getCenter()) - right->getRadius(), right)); return std::make_pair(-1, std::numeric_limits<float>::max()); }