Enum roles_logic_sv2::handlers::SendTo_
source · pub enum SendTo_<Message, Remote> {
RelayNewMessageToRemote(Arc<Mutex<Remote>>, Message),
RelaySameMessageToRemote(Arc<Mutex<Remote>>),
RelayNewMessage(Message),
Respond(Message),
Multiple(Vec<SendTo_<Message, Remote>>),
None(Option<Message>),
}
Expand description
Message is a serializable entity that rapresent the meanings of communication between Remote(s) SendTo_ is used to add context to Message, it say what we need to do with that Message.
Variants§
RelayNewMessageToRemote(Arc<Mutex<Remote>>, Message)
Used by proxies when Message must be relayed downstream or upstream and we want to specify to which particular downstream or upstream we want to relay the message.
When the message that we need to relay is the same message that we received should be used RelaySameMessageToRemote in order to save an allocation.
RelaySameMessageToRemote(Arc<Mutex<Remote>>)
Used by proxies when Message must be relayed downstream or upstream and we want to specify to which particular downstream or upstream we want to relay the message.
Is used when we need to relay the same message the we received in order to save an allocation.
RelayNewMessage(Message)
Used by proxies when Message must be relayed downstream or upstream and we do not want to specify specify to which particular downstream or upstream we want to relay the message.
This is used in proxies that do and Sv1 to Sv2 translation. The upstream is connected via an extended channel that means that
Respond(Message)
Used proxies clients and servers to directly respond to a received message.
Multiple(Vec<SendTo_<Message, Remote>>)
None(Option<Message>)
Used by proxies, clients, and servers, when Message do not have to be used in any of the above way. If Message is still needed to be used in a non conventional way we use SendTo::None(Some(message)) If we just want to discard it we can use SendTo::None(None)
SendTo::None(Some(m)) could be used for example when we do not need to send the message, but we still need it for successive handling/transformation. One of these cases are proxies that are connected to upstream via an extended channel (like the Sv1 <-> Sv2 translator). This because extended channel messages are always general for all the downstream, where standard channel message can be specific for a particular downstream. Another case is when 2 roles are implemented in the same software, like a pool that is both TP client and a Mining server, messages received by the TP client must be sent to the Mining Server than transformed in Mining messages and sent to the downstream.