forked from tornado-packages/tornado-core
Include events from cache to be audited and saved
This commit is contained in:
parent
69f89ae597
commit
68fcf07c2a
7
dist/index.js
vendored
7
dist/index.js
vendored
@ -2327,13 +2327,14 @@ class BaseEventsService {
|
|||||||
return !hasEvent;
|
return !hasEvent;
|
||||||
});
|
});
|
||||||
const lastBlock = newEvents.lastBlock || allEvents[allEvents.length - 1]?.blockNumber;
|
const lastBlock = newEvents.lastBlock || allEvents[allEvents.length - 1]?.blockNumber;
|
||||||
|
const unknownEvents = savedEvents.fromCache ? allEvents : newEvents.events;
|
||||||
const validateResult = await this.validateEvents({
|
const validateResult = await this.validateEvents({
|
||||||
events: allEvents,
|
events: allEvents,
|
||||||
newEvents: newEvents.events,
|
newEvents: unknownEvents,
|
||||||
lastBlock
|
lastBlock
|
||||||
});
|
});
|
||||||
if (savedEvents.fromCache || newEvents.events.length) {
|
if (unknownEvents.length) {
|
||||||
await this.saveEvents({ events: allEvents, newEvents: newEvents.events, lastBlock });
|
await this.saveEvents({ events: allEvents, newEvents: unknownEvents, lastBlock });
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
events: allEvents,
|
events: allEvents,
|
||||||
|
7
dist/index.mjs
vendored
7
dist/index.mjs
vendored
@ -2305,13 +2305,14 @@ class BaseEventsService {
|
|||||||
return !hasEvent;
|
return !hasEvent;
|
||||||
});
|
});
|
||||||
const lastBlock = newEvents.lastBlock || allEvents[allEvents.length - 1]?.blockNumber;
|
const lastBlock = newEvents.lastBlock || allEvents[allEvents.length - 1]?.blockNumber;
|
||||||
|
const unknownEvents = savedEvents.fromCache ? allEvents : newEvents.events;
|
||||||
const validateResult = await this.validateEvents({
|
const validateResult = await this.validateEvents({
|
||||||
events: allEvents,
|
events: allEvents,
|
||||||
newEvents: newEvents.events,
|
newEvents: unknownEvents,
|
||||||
lastBlock
|
lastBlock
|
||||||
});
|
});
|
||||||
if (savedEvents.fromCache || newEvents.events.length) {
|
if (unknownEvents.length) {
|
||||||
await this.saveEvents({ events: allEvents, newEvents: newEvents.events, lastBlock });
|
await this.saveEvents({ events: allEvents, newEvents: unknownEvents, lastBlock });
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
events: allEvents,
|
events: allEvents,
|
||||||
|
7
dist/tornado.umd.js
vendored
7
dist/tornado.umd.js
vendored
@ -92334,13 +92334,14 @@ class BaseEventsService {
|
|||||||
return !hasEvent;
|
return !hasEvent;
|
||||||
});
|
});
|
||||||
const lastBlock = newEvents.lastBlock || allEvents[allEvents.length - 1]?.blockNumber;
|
const lastBlock = newEvents.lastBlock || allEvents[allEvents.length - 1]?.blockNumber;
|
||||||
|
const unknownEvents = savedEvents.fromCache ? allEvents : newEvents.events;
|
||||||
const validateResult = await this.validateEvents({
|
const validateResult = await this.validateEvents({
|
||||||
events: allEvents,
|
events: allEvents,
|
||||||
newEvents: newEvents.events,
|
newEvents: unknownEvents,
|
||||||
lastBlock
|
lastBlock
|
||||||
});
|
});
|
||||||
if (savedEvents.fromCache || newEvents.events.length) {
|
if (unknownEvents.length) {
|
||||||
await this.saveEvents({ events: allEvents, newEvents: newEvents.events, lastBlock });
|
await this.saveEvents({ events: allEvents, newEvents: unknownEvents, lastBlock });
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
events: allEvents,
|
events: allEvents,
|
||||||
|
2
dist/tornado.umd.min.js
vendored
2
dist/tornado.umd.min.js
vendored
File diff suppressed because one or more lines are too long
@ -276,15 +276,17 @@ export class BaseEventsService<EventType extends MinimalEvents> {
|
|||||||
|
|
||||||
const lastBlock = newEvents.lastBlock || allEvents[allEvents.length - 1]?.blockNumber;
|
const lastBlock = newEvents.lastBlock || allEvents[allEvents.length - 1]?.blockNumber;
|
||||||
|
|
||||||
|
const unknownEvents = (savedEvents as CachedEvents<EventType>).fromCache ? allEvents : newEvents.events;
|
||||||
|
|
||||||
const validateResult = await this.validateEvents<S>({
|
const validateResult = await this.validateEvents<S>({
|
||||||
events: allEvents,
|
events: allEvents,
|
||||||
newEvents: newEvents.events,
|
newEvents: unknownEvents,
|
||||||
lastBlock,
|
lastBlock,
|
||||||
});
|
});
|
||||||
|
|
||||||
// If the events are loaded from cache or we have found new events, save them
|
// If the events are loaded from cache or we have found new events, save them
|
||||||
if ((savedEvents as CachedEvents<EventType>).fromCache || newEvents.events.length) {
|
if (unknownEvents.length) {
|
||||||
await this.saveEvents({ events: allEvents, newEvents: newEvents.events, lastBlock });
|
await this.saveEvents({ events: allEvents, newEvents: unknownEvents, lastBlock });
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user