From 0eaa008810f53bc08be704ea8c04900989565add Mon Sep 17 00:00:00 2001 From: Scott Lystig Fritchie Date: Thu, 27 Aug 2015 20:27:24 +0900 Subject: [PATCH] Change checksum algorithm to exclude 'flap' also --- src/machi_projection.erl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/machi_projection.erl b/src/machi_projection.erl index 68d2998..9773fbb 100644 --- a/src/machi_projection.erl +++ b/src/machi_projection.erl @@ -111,8 +111,19 @@ new(EpochNum, MyName, [] = _MembersDict0, _Down_list, _UPI_list,_Repairing_list, %% @doc Update the checksum element of a projection record. update_checksum(P) -> + %% Fields that we ignore when calculating checksum: + %% * epoch_csum + %% * dbg2: humming consensus participants may modify this at will without + %% voiding the identity of the projection as a whole. + %% * flap: In some cases in CP mode, coode upstream of C120 may have + %% updated the flapping information. That's OK enough: we aren't + %% going to violate chain replication safety rules (or + %% accidentally encourage someone else sometime later) by + %% replacing flapping information with our own local view at + %% this instant in time. CSum = crypto:hash(sha, term_to_binary(P#projection_v1{epoch_csum= <<>>, + flap=undefined, dbg2=[]})), P#projection_v1{epoch_csum=CSum}.