|
|
@ -348,10 +348,7 @@ const getOlderHistory = function (data, cb) {
|
|
|
|
if (hash === oldestKnownHash) {
|
|
|
|
if (hash === oldestKnownHash) {
|
|
|
|
found = true;
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
messages.push({
|
|
|
|
messages.push(parsed);
|
|
|
|
msg: parsed,
|
|
|
|
|
|
|
|
hash: hash,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}, function (err) {
|
|
|
|
}, function (err) {
|
|
|
|
var toSend = [];
|
|
|
|
var toSend = [];
|
|
|
|
if (typeof (desiredMessages) === "number") {
|
|
|
|
if (typeof (desiredMessages) === "number") {
|
|
|
@ -359,14 +356,14 @@ const getOlderHistory = function (data, cb) {
|
|
|
|
} else if (untilHash) {
|
|
|
|
} else if (untilHash) {
|
|
|
|
for (var j = messages.length - 1; j >= 0; j--) {
|
|
|
|
for (var j = messages.length - 1; j >= 0; j--) {
|
|
|
|
toSend.unshift(messages[j]);
|
|
|
|
toSend.unshift(messages[j]);
|
|
|
|
if (messages[j] && messages[j].hash === untilHash) {
|
|
|
|
if (Array.isArray(messages[j]) && HK.getHash(messages[j][4]) === untilHash) {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
let cpCount = 0;
|
|
|
|
let cpCount = 0;
|
|
|
|
for (var i = messages.length - 1; i >= 0; i--) {
|
|
|
|
for (var i = messages.length - 1; i >= 0; i--) {
|
|
|
|
if (/^cp\|/.test(messages[i].msg[4]) && i !== (messages.length - 1)) {
|
|
|
|
if (/^cp\|/.test(messages[i][4]) && i !== (messages.length - 1)) {
|
|
|
|
cpCount++;
|
|
|
|
cpCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
toSend.unshift(messages[i]);
|
|
|
|
toSend.unshift(messages[i]);
|
|
|
|