Skip to content

Commit

Permalink
>= on max_cursor_age
Browse files Browse the repository at this point in the history
  • Loading branch information
bryzettler committed Dec 24, 2024
1 parent 4996f97 commit ca1954c
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,17 @@ export const setupSubstream = async (
const cursorDate = new Date(lastCursor.dataValues.createdAt);
const cursorAge =
(Date.now() - cursorDate.getTime()) / (24 * 60 * 60 * 1000);

if (cursorAge > SUBSTREAM_CURSOR_MAX_AGE_DAYS) {
if (cursorAge >= SUBSTREAM_CURSOR_MAX_AGE_DAYS) {
console.log(
`Cursor is ${Math.floor(
cursorAge
`Cursor is ${cursorAge.toFixed(
1
)} days old, starting from current block`
);
cursor = undefined;
} else {
cursor = lastCursor.cursor;
console.log(
`Using existing cursor from ${Math.floor(cursorAge)} days ago`
`Using existing cursor from ${cursorAge.toFixed(1)} days ago`
);
}
} else {
Expand Down

0 comments on commit ca1954c

Please sign in to comment.