WIP history-keeper fixes

This commit is contained in:
ansuz
2020-04-01 11:48:16 -04:00
parent 1a825ad664
commit ed5d97f899
3 changed files with 79 additions and 25 deletions

View File

@@ -153,7 +153,8 @@ const computeIndex = function (data, cb) {
messageBuf = [];
}
} else if (messageBuf.length > 100 && cpIndex.length === 0) {
messageBuf = messageBuf.slice(0, 50);
// take the last 50 messages
messageBuf = messageBuf.slice(-50);
}
// if it's not metadata or a checkpoint then it should be a regular message
// store it in the buffer
@@ -352,7 +353,8 @@ const getMultipleFileSize = function (data, cb) {
const getHashOffset = function (data, cb) {
const channelName = data.channel;
const lastKnownHash = data.lastKnownHash;
const lastKnownHash = data.hash;
if (typeof(lastKnownHash) !== 'string') { return void cb("INVALID_HASH"); }
var offset = -1;
store.readMessagesBin(channelName, 0, (msgObj, readMore, abort) => {