Skip to content
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

Merged
merged 7 commits into from Dec 21, 2020
Merged

Median time emitter #131

merged 7 commits into from Dec 21, 2020

Conversation

classicalliu
Copy link
Contributor

No description provided.

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());
Copy link
Collaborator

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.

add(key, value) {
const v = this.map.get(key);
if (v === undefined) {
this.map = this.map.set(key, {
Copy link
Collaborator

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;

@classicalliu classicalliu merged commit 8ebafca into develop Dec 21, 2020
@classicalliu classicalliu deleted the median-time-emitter branch December 21, 2020 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants