more EUNKNOWN

pull/1/head
yflory 4 years ago
parent d2fb68642d
commit e5af30d678

@ -357,7 +357,7 @@ const storeMessage = function (Env, channel, msg, isCp, optionalMessageHash) {
if (offsetCount < 0) { if (offsetCount < 0) {
Log.warn('OFFSET_TRIM_OOO', { Log.warn('OFFSET_TRIM_OOO', {
channel: id, channel: id,
map: index.OffsetByHash map: index.offsetByHash
}); });
} else if (offsetCount > 0) { } else if (offsetCount > 0) {
trimOffsetByOrder(index.offsetByHash, index.offsets); trimOffsetByOrder(index.offsetByHash, index.offsets);
@ -445,6 +445,14 @@ const getHistoryOffset = (Env, channelName, lastKnownHash, _cb) => {
return void cb(new Error('EUNKNOWN')); return void cb(new Error('EUNKNOWN'));
} }
// If we asked for a lastKnownHash but didn't find it AND if
// this channel has checkpoints, send EUNKNOWN so that the
// client can ask for normal history (without lastKnownHash)
if (lastKnownHash && !lkh && index.cpIndex.length) {
waitFor.abort();
return void cb(new Error('EUNKNOWN'));
}
// Otherwise use our lastKnownHash // Otherwise use our lastKnownHash
cb(null, lkh); cb(null, lkh);
})); }));

Loading…
Cancel
Save