private void OnAccepted(Accepted accepted) { knownAcceptors.Add(accepted.Originator); LearnerState state; if (learnerState.TryGetValue(accepted.ProposalNumber, out state) == false) { learnerState[accepted.ProposalNumber] = new LearnerState { BallotNumber = accepted.BallotNumber, NumberOfAccepts = 1, ProposalNumber = accepted.ProposalNumber }; } else if (state.BallotNumber < accepted.BallotNumber) { return; } else if (state.Accepted == false) { log.DebugFormat("Value accepted for {0}", state.ProposalNumber); state.NumberOfAccepts += 1; if (state.NumberOfAccepts < acceptorsCount / 2) return; while (Commands.Count < state.ProposalNumber) Commands.Add(null); state.Accepted = true; Commands[state.ProposalNumber - 1] = accepted.Value; } }
private void OnAccepted(Accepted accepted) { ProposalState state; if (proposalsState.TryGetValue(accepted.ProposalNumber, out state) == false) return; state.NumberOfAccepts += 1; if (state.NumberOfAccepts <= acceptors.Length/2) return; proposalsState.Remove(state.ProposalNumber); }