New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Median time emitter #131
Median time emitter #131
Conversation
let block_emitter = block_emitter.borrow(&guard); | ||
let native_indexer = this.borrow_mut(&guard); | ||
let mut block_emitters = native_indexer.block_emitters.write().unwrap(); | ||
block_emitters.push(block_emitter.clone()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we only need one block emitter, each median time emitter can subscribe from this single block emitter.
packages/indexer/lib/index.js
Outdated
add(key, value) { | ||
const v = this.map.get(key); | ||
if (v === undefined) { | ||
this.map = this.map.set(key, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All you need here is a plain Map, you can do:
const map = Map();
map[v] = map[v] || 0;
map[v] = map[v] + 1;
No description provided.