-
Notifications
You must be signed in to change notification settings - Fork 15
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
frank/usermap #14
frank/usermap #14
Conversation
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.
would be good to add doc comments to the methods
} | ||
|
||
pub fn get(&self, pubkey: &str) -> Option<User> { | ||
self.usermap.get(pubkey).map(|user| user.value().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.
is it possible to return &User? the caller can clone if they need
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.
without using Cow i don't think so and i'd really rather not use Cow, cloning 4.3kb shouldn't be that expensive
pub struct Usermap { | ||
subscribed: bool, | ||
subscription: WebsocketProgramAccountSubscriber, | ||
usermap: Arc<DashMap<String, User>>, |
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.
is String helpful here?
usermap: Arc<DashMap<String, User>>, | |
usermap: Arc<DashMap<Pubkey, User>>, |
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.
the pubkeys come out of the events as strings, i think keeping it string makes sense
if let Some(update) = event.as_any().downcast_ref::<ProgramAccountUpdate<User>>() { | ||
let user_data_and_slot = update.data_and_slot.clone(); | ||
let user_pubkey = update.pubkey.to_string(); | ||
if update.data_and_slot.slot > latest_slot.load(Ordering::Relaxed) { |
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.
maybe >=
? so updates from different user in the same slot should both go through
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.
the data updates will still go through, it just won't go to the effort of updating the latest slot if it's the same slot
No description provided.