BaseBulkRound::BaseBulkRound(const Group &group, const PrivateIdentity &ident, const Id &round_id, const QSharedPointer<Network> &network, GetDataCallback &get_data, const QSharedPointer<BuddyMonitor> &bm, CreateRound create_shuffle) : Round(group, ident, round_id, network, get_data, bm), _get_shuffle_data(this, &BaseBulkRound::GetShuffleData) { QVariantHash headers = GetNetwork()->GetHeaders(); headers["bulk"] = true; GetNetwork()->SetHeaders(headers); QSharedPointer<Network> net(GetNetwork()->Clone()); headers["bulk"] = false; net->SetHeaders(headers); Id sr_id(Hash().ComputeHash(GetRoundId().GetByteArray())); _shuffle_round = create_shuffle(GetGroup(), GetPrivateIdentity(), sr_id, net, _get_shuffle_data, bm); _shuffle_round->SetSink(&_shuffle_sink); QObject::connect(_shuffle_round.data(), SIGNAL(Finished()), this, SLOT(SlotShuffleFinished())); }
void Session::HandlePrepare(const Request ¬ification) { if(_prepare_waiting) { _prepare_waiting = false; } QVariantHash msg = notification.GetData().toHash(); if(_current_round && !_current_round->Stopped() && _current_round->Started()) { _prepare_waiting = true; _prepare_notification = notification; if(msg.value("interrupt").toBool()) { _current_round->Stop("Round interrupted."); } return; } QByteArray brid = msg.value("round_id").toByteArray(); if(brid.isEmpty()) { qDebug() << "HandlePrepare: Invalid round id"; return; } Id round_id(brid); if(msg.contains("group")) { QDataStream stream(msg.value("group").toByteArray()); Group group; stream >> group; qDebug() << "Prepare contains new group. I am present:" << group.Contains(GetPrivateIdentity().GetLocalId()); _group_holder->UpdateGroup(group); }
void Session::Registered(const Response &response) { if(Stopped()) { return; } if(response.Successful() && response.GetData().toBool()) { qDebug() << GetPrivateIdentity().GetLocalId() << "registered and waiting to go."; return; } if(!_register_event.Stopped()) { qDebug() << "Almost started two registration attempts simultaneously!"; return; } int delay = 5000; if(response.GetErrorType() == Response::Other) { delay = 60000; } qDebug() << "Unable to register due to" << response.GetError() << "Trying again later."; Dissent::Utils::TimerCallback *cb = new Dissent::Utils::TimerMethod<Session, int>(this, &Session::Register, 0); _register_event = Dissent::Utils::Timer::GetInstance().QueueCallback(cb, delay); }
void BulkRound::PrepareBlameShuffle() { QSharedPointer<Network> net(GetNetwork()->Clone()); QVariantHash headers = net->GetHeaders(); headers["bulk"] = false; net->SetHeaders(headers); Hash hashalgo; QByteArray roundid = GetRoundId().GetByteArray(); roundid = hashalgo.ComputeHash(roundid); roundid = hashalgo.ComputeHash(roundid); Id sr_id(roundid); _shuffle_round = _create_shuffle(GetGroup(), GetPrivateIdentity(), sr_id, net, _get_blame_data); _shuffle_round->SetSink(&_shuffle_sink); QObject::connect(_shuffle_round.data(), SIGNAL(Finished()), this, SLOT(BlameShuffleFinished())); }