diff --git a/src/machi_chain_manager1.erl b/src/machi_chain_manager1.erl index a1eb0f5..d4c2f37 100644 --- a/src/machi_chain_manager1.erl +++ b/src/machi_chain_manager1.erl @@ -1337,13 +1337,37 @@ react_to_env_C100(P_newprop, P_latest, I_am_UPI_in_newprop_p = lists:member(MyName, P_newprop#projection_v1.upi), I_am_Repairing_in_latest_p = lists:member(MyName, P_latest#projection_v1.repairing), - Current_sane_p = projection_transition_is_sane(P_current, P_latest, - MyName), + Sane_p = fun(X, Y) -> + case projection_transition_is_sane(X, Y, MyName) of + true -> true; + _ -> false + end end, + Current_sane_p = Sane_p(P_current, P_latest), + %% Inner = fun(P) -> case inner_projection_exists(P) of true -> t; + %% false -> f + %% end end, + %% io:format(user, "~w:~w.~w,", [MyName, Inner(P_current), Inner(P_latest)]), timer:sleep(50), + Inner_sane_p = + case inner_projection_exists(P_current) + andalso + inner_projection_exists(P_latest) of + true -> + P_currentIx = inner_projection_or_self(P_current), + P_currentIxE = P_currentIx#projection_v1.epoch_number, + P_currentI = P_currentIx#projection_v1{epoch_number=P_currentIxE-1}, + P_latestI = inner_projection_or_self(P_latest), + io:format(user, "i=~w>?i=~w,", [P_currentI#projection_v1.epoch_number, P_latestI#projection_v1.epoch_number]), + Sane_p(P_currentI, P_latestI); + false -> + true + end, put(xxx_hack, [{p_current, machi_projection:make_summary(P_current)}, {epoch_compare, P_latest#projection_v1.epoch_number > P_current#projection_v1.epoch_number}, {i_am_upi_in_newprop_p, I_am_UPI_in_newprop_p}, - {i_am_repairing_in_latest_p, I_am_Repairing_in_latest_p}]), - case Current_sane_p of + {i_am_repairing_in_latest_p, I_am_Repairing_in_latest_p}, + {current_sane_p, Current_sane_p}, + {inner_sane_p, Inner_sane_p}]), + case Current_sane_p andalso Inner_sane_p of _ when P_current#projection_v1.epoch_number == 0 -> %% Epoch == 0 is reserved for first-time, just booting conditions. ?REACT({c100, ?LINE, [first_write]}), @@ -1628,6 +1652,18 @@ projection_transition_is_sane_retrospective(P1, P2, RelativeToServer) -> -endif. % TEST projection_transition_is_sane( + #projection_v1{epoch_number=Epoch1} = P1, + #projection_v1{epoch_number=Epoch2} = P2, + RelativeToServer, RetrospectiveP) -> + case projection_transition_is_sane_except_epoch( + P1, P2, RelativeToServer, RetrospectiveP) of + true -> + Epoch2 > Epoch1; + Else -> + Else + end. + +projection_transition_is_sane_except_epoch( #projection_v1{epoch_number=Epoch1, epoch_csum=CSum1, creation_time=CreationTime1, @@ -1666,7 +1702,6 @@ projection_transition_is_sane( true = is_list(Repairing_list1) andalso is_list(Repairing_list2), true = is_list(Dbg1) andalso is_list(Dbg2), - true = Epoch2 > Epoch1, All_list1 = All_list2, % todo will probably change %% No duplicates diff --git a/src/machi_projection.erl b/src/machi_projection.erl index 3d94cb1..9ac98b3 100644 --- a/src/machi_projection.erl +++ b/src/machi_projection.erl @@ -141,6 +141,7 @@ compare(#projection_v1{epoch_number=E1}, %% @doc Create a proplist-style summary of a projection record. make_summary(#projection_v1{epoch_number=EpochNum, + epoch_csum= <<_CSum4:4/binary, _/binary>>=_CSum, all_members=_All_list, down=Down_list, author_server=Author, @@ -149,7 +150,7 @@ make_summary(#projection_v1{epoch_number=EpochNum, dbg=Dbg, dbg2=Dbg2}) -> [{epoch,EpochNum},{author,Author}, {upi,UPI_list},{repair,Repairing_list},{down,Down_list}, - {d,Dbg}, {d2,Dbg2}]. + {d,Dbg}, {d2,Dbg2}, {csum4, _CSum4}]. %% @doc Make a `p_srvr_dict()' out of a list of `p_srvr()' or out of a %% `p_srvr_dict()'.