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