void ConstructOverlay(int count, QVector<TestNode *> &nodes, Group *&group, bool make_keys) { QVector<Id> ids; QVector<AsymmetricKey *> signing_keys; for(int idx = 0; idx < count; idx++) { nodes.append(new TestNode(idx+1, make_keys)); ids.append(nodes[idx]->cm.GetId()); if(make_keys) { signing_keys.append(nodes[idx]->key->GetPublicKey()); } } group = new Group(ids, signing_keys); for(int idx = 0; idx < count; idx++) { for(int jdx = 0; jdx < count; jdx++) { if(idx == jdx) { continue; } nodes[idx]->cm.ConnectTo(BufferAddress(jdx+1)); } } qint64 next = Timer::GetInstance().VirtualRun(); while(next != -1) { Time::GetInstance().IncrementVirtualClock(next); next = Timer::GetInstance().VirtualRun(); } }
void BufferEdgeListener::OnStart() { EdgeListener::OnStart(); const BufferAddress addr = static_cast<const BufferAddress &>(GetAddress()); int id = addr.GetId(); if(id == 0) { while(_el_map.contains(id = Random::GetInstance().GetInt(1))); SetAddress(BufferAddress(id)); } if(_el_map.contains(id)) { qWarning() << "Attempting to create two BufferEdgeListeners with the same" << " address: " << addr.ToString(); return; } _valid = true; _el_map[id] = this; }