This commit is contained in:
19
lib/paxos.ex
19
lib/paxos.ex
@@ -228,9 +228,7 @@ defmodule Paxos do
|
||||
safecast(proc, {:prepared, inst, ballot, state.instmap[inst].accepted_ballot, state.instmap[inst].accepted_value});
|
||||
|
||||
set_instmap do
|
||||
%{ map
|
||||
| ballot: ballot
|
||||
}
|
||||
%{ map | ballot: ballot }
|
||||
end
|
||||
|
||||
Ballot.compare(ballot, &>/2, state.instmap[inst].ballot) ->
|
||||
@@ -240,9 +238,7 @@ defmodule Paxos do
|
||||
)
|
||||
|
||||
set_instmap do
|
||||
%{ map
|
||||
| ballot: ballot
|
||||
}
|
||||
%{ map | ballot: ballot }
|
||||
end
|
||||
|
||||
true ->
|
||||
@@ -257,7 +253,7 @@ defmodule Paxos do
|
||||
has_finished(state, inst) ->
|
||||
state
|
||||
|
||||
state.leader == state.name and Ballot.compare(state.instmap[inst].ballot, &==/2, ballot) ->
|
||||
state.leader == state.name and state.instmap[inst].ballot == ballot ->
|
||||
if Map.has_key?(state.instmap, inst) and state.instmap[inst].pid_to_inform != nil do
|
||||
send(state.instmap[inst].pid_to_inform, {:abort, inst})
|
||||
end
|
||||
@@ -300,10 +296,9 @@ defmodule Paxos do
|
||||
has_finished(state, inst) ->
|
||||
state
|
||||
|
||||
Ballot.compare(ballot, &==/2, state.instmap[inst].ballot) ->
|
||||
ballot == state.instmap[inst].ballot ->
|
||||
set_instmap do
|
||||
%{
|
||||
map
|
||||
%{ map
|
||||
| prepared_values: map.prepared_values ++ [{accepted_ballot, accepted_value}]
|
||||
}
|
||||
end
|
||||
@@ -354,9 +349,7 @@ defmodule Paxos do
|
||||
|
||||
state.leader == state.name and state.instmap[inst].ballot == ballot ->
|
||||
set_instmap do
|
||||
%{ map |
|
||||
accepted: map.accepted + 1
|
||||
}
|
||||
%{ map | accepted: map.accepted + 1 }
|
||||
end
|
||||
|
||||
accepted( state, inst)
|
||||
|
||||
Reference in New Issue
Block a user