small change to chainpad in order to make it more likely to fail if the authDoc goes into the wrong state

pull/1/head
Caleb James DeLisle 9 years ago
parent f3fb674504
commit b372b0b77c

@ -1043,12 +1043,18 @@ var handleMessage = ChainPad.handleMessage = function (realtime, msgStr) {
authDocAtTimeOfPatch = Patch.apply(toApply[i].content, authDocAtTimeOfPatch); authDocAtTimeOfPatch = Patch.apply(toApply[i].content, authDocAtTimeOfPatch);
} }
if (Sha.hex_sha256(authDocAtTimeOfPatch) !== patch.parentHash) { var authDocHashAtTimeOfPatch = Sha.hex_sha256(authDocAtTimeOfPatch);
if (authDocHashAtTimeOfPatch !== patch.parentHash) {
debug(realtime, "patch [" + msg.hashOf + "] parentHash is not valid"); debug(realtime, "patch [" + msg.hashOf + "] parentHash is not valid");
if (Common.PARANOIA) { check(realtime); } if (Common.PARANOIA) { check(realtime); }
//delete realtime.messages[msg.hashOf]; //delete realtime.messages[msg.hashOf];
return; return;
} }
if (authDocAtTimeOfPatch === realtime.authDoc &&
authDocHashAtTimeOfPatch !== realtime.best.inverseOf.parentHash)
{
throw new Error("authDoc does not match chain head");
}
var simplePatch = var simplePatch =
Patch.simplify(patch, authDocAtTimeOfPatch, realtime.config.operationSimplify); Patch.simplify(patch, authDocAtTimeOfPatch, realtime.config.operationSimplify);

Loading…
Cancel
Save