diff --git a/lib/hk-util.js b/lib/hk-util.js index 5fd5d2158..a48358cc3 100644 --- a/lib/hk-util.js +++ b/lib/hk-util.js @@ -437,8 +437,13 @@ const getHistoryOffset = (Env, channelName, lastKnownHash, _cb) => { // check if the "hash" the client is requesting exists in the index const lkh = index.offsetByHash[lastKnownHash]; - // Hash too old or no longer exists, empty cache + // lastKnownHash requested but not found in the index if (lastKnownHash && typeof(lkh) !== "number") { + // No checkpoint: may be a non-chainpad channel + if (!index.cpIndex.length) { + return; + } + // Hash too old or no longer exists, empty cache waitFor.abort(); return void cb(new Error('EUNKNOWN')); } @@ -469,14 +474,6 @@ const getHistoryOffset = (Env, channelName, lastKnownHash, _cb) => { 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 cb(null, lkh); }));