feat: skip saving events to the db (#81)
This commit is contained in:
parent
30d78e8393
commit
006a1e8f49
|
@ -22,7 +22,7 @@ class EventSyncer {
|
|||
|
||||
const observable = new Observable(subscriber => {
|
||||
const cb = this.callbackFactory(subscriber, filters, eventKey, eventName);
|
||||
const fnDBEvents = this.serveDBEvents(cb, eventKey);
|
||||
const fnDBEvents = this.serveDBEvents(cb, eventKey, !filterConditions.saveToDb);
|
||||
const fnPastEvents = this.getPastEvents(cb, eventKey, contractInstance, eventName, filters);
|
||||
const fnSubscribe = this.isWebsocketProvider ? this.subscribeToEvent(cb, contractInstance, eventName) : null;
|
||||
|
||||
|
@ -58,7 +58,9 @@ class EventSyncer {
|
|||
return false;
|
||||
};
|
||||
|
||||
serveDBEvents = (cb, eventKey) => (toBlock, lastCachedBlock) => {
|
||||
serveDBEvents = (cb, eventKey, fromDB) => (toBlock, lastCachedBlock) => {
|
||||
if(!fromDB) return false;
|
||||
|
||||
const events = this.db.getEventsFor(eventKey);
|
||||
events.forEach(ev => cb(null, ev));
|
||||
|
||||
|
@ -116,7 +118,9 @@ class EventSyncer {
|
|||
|
||||
subscriber.next(eventData.returnValues);
|
||||
|
||||
this.events.emit("updateDB", {eventKey, eventData});
|
||||
if (filterConditions && !!filterConditions.saveToDb) {
|
||||
this.events.emit("updateDB", {eventKey, eventData});
|
||||
}
|
||||
};
|
||||
|
||||
close() {
|
||||
|
|
|
@ -104,14 +104,14 @@ export default class Subspace {
|
|||
}, 100);
|
||||
}
|
||||
|
||||
SubspaceContract.trackEvent = (eventName, filterConditionsOrCb) => {
|
||||
return this.trackEvent(SubspaceContract, eventName, filterConditionsOrCb);
|
||||
SubspaceContract.trackEvent = (eventName, filterConditions) => {
|
||||
return this.trackEvent(SubspaceContract, eventName, filterConditions);
|
||||
};
|
||||
|
||||
Object.keys(SubspaceContract.events).forEach(ev => {
|
||||
if (!SubspaceContract.options.jsonInterface.find(x => x.type === "event" && x.name == ev)) return;
|
||||
SubspaceContract.events[ev].track = filterConditionsOrCb =>
|
||||
this.trackEvent(SubspaceContract, ev, filterConditionsOrCb);
|
||||
SubspaceContract.events[ev].track = filterConditions =>
|
||||
this.trackEvent(SubspaceContract, ev, filterConditions);
|
||||
});
|
||||
|
||||
SubspaceContract.trackProperty = (propName, methodArgs, callArgs) => {
|
||||
|
|
Loading…
Reference in New Issue