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

[stratumv2_lib]: Figure out design for networked message handling #174

Open
ccdle12 opened this issue Jun 8, 2021 · 0 comments
Open

[stratumv2_lib]: Figure out design for networked message handling #174

ccdle12 opened this issue Jun 8, 2021 · 0 comments

Comments

@ccdle12
Copy link
Owner

ccdle12 commented Jun 8, 2021

Different devices cover different areas of the sub protocol and therefore would only be handling certain messages.

A few ideas for the design:

  • A MessageHandler struct that contains a HashMap<MessageType, Fn(), allowing a caller to assign a handler function to certain message types

  • More strictly defined traits by device e.g. PoolServer { fn on_message_xyz() }. This requires the implementation for each message that must be handled by that component.

  • More strictly defined traits by areas of responsiblity NOT by device e.g. ExtendedMiner { fn on_extended_xyz() }, StandardMiner { fn on_standard_xyz () }

  • Each component would need to implement a trait or just a simple method to match networked messages to the appropriate handler

pub struct ConcerteMiner {...}

impl ExtendedMiner for ConcreteMiner {
  fn on_open_extended_channel_msg() {...}
}
impl StandardMiner for ConcreteMiner{
  fn on_open_standard_channel_msg() {...}
}

impl NetworkMessageHandler {
   fn receive_message(&self, message: &Message) {
      match message.message_type {
         OpenStandardMiningChannel => self.on_open_standard_mining_channel(message),
      }
   }
}
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

No branches or pull requests

1 participant