added get_game_state
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-01-16 22:06:10 +00:00
parent 47b02d37ec
commit 1d2db555be
2 changed files with 89 additions and 56 deletions

View File

@@ -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)