reverse caching: optimize timing

Users quickly want all reverses registered in the path,
but don't care so much about live data.
This commit is contained in:
Jannis R 2017-01-05 17:20:10 +01:00
parent 6f492a4945
commit 71e80f10d8
No known key found for this signature in database
GPG Key ID: 0FE83946296A88A5

View File

@ -25,7 +25,7 @@ export default class RegistryMiddleware {
toMiddleware () {
return (store) => {
const api = Contracts.get()._api;
let contract, confirmedEvents, removedEvents, interval;
let contract, confirmedEvents, removedEvents, timeout, interval;
let addressesToCheck = {};
@ -77,7 +77,8 @@ export default class RegistryMiddleware {
removedEvents = subscribeToEvent(_contract, 'ReverseRemoved');
removedEvents.on('log', onLog);
interval = setInterval(checkReverses, 2000);
timeout = setTimeout(checkReverses, 5000);
interval = setInterval(checkReverses, 20000);
})
.catch((err) => {
console.error('Failed to start caching reverses:', err);
@ -95,6 +96,9 @@ export default class RegistryMiddleware {
if (interval) {
clearInterval(interval);
}
if (timeout) {
clearTimeout(timeout);
}
break;
default:
@ -103,4 +107,4 @@ export default class RegistryMiddleware {
};
};
}
};
}