mirror of
https://github.com/serai-dex/serai.git
synced 2025-01-22 02:34:55 +00:00
Sub-CoordinatorMessage -> CoordinatorMessage via From/Into
This commit is contained in:
parent
e3de64d5ff
commit
a2493cfafc
1 changed files with 22 additions and 0 deletions
|
@ -175,6 +175,16 @@ pub mod substrate {
|
|||
}
|
||||
}
|
||||
|
||||
macro_rules! impl_from {
|
||||
($from: ident, $to: ident, $via: ident) => {
|
||||
impl From<$from::$to> for $to {
|
||||
fn from(msg: $from::$to) -> $to {
|
||||
$to::$via(msg)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||
pub enum CoordinatorMessage {
|
||||
KeyGen(key_gen::CoordinatorMessage),
|
||||
|
@ -183,6 +193,11 @@ pub enum CoordinatorMessage {
|
|||
Substrate(substrate::CoordinatorMessage),
|
||||
}
|
||||
|
||||
impl_from!(key_gen, CoordinatorMessage, KeyGen);
|
||||
impl_from!(sign, CoordinatorMessage, Sign);
|
||||
impl_from!(coordinator, CoordinatorMessage, Coordinator);
|
||||
impl_from!(substrate, CoordinatorMessage, Substrate);
|
||||
|
||||
impl CoordinatorMessage {
|
||||
pub fn required_block(&self) -> Option<BlockHash> {
|
||||
let required = match self {
|
||||
|
@ -209,6 +224,13 @@ pub enum ProcessorMessage {
|
|||
Substrate(substrate::ProcessorMessage),
|
||||
}
|
||||
|
||||
impl_from!(key_gen, ProcessorMessage, KeyGen);
|
||||
impl_from!(sign, ProcessorMessage, Sign);
|
||||
impl_from!(coordinator, ProcessorMessage, Coordinator);
|
||||
impl_from!(substrate, ProcessorMessage, Substrate);
|
||||
|
||||
// Intent generation code
|
||||
|
||||
const COORDINATOR_UID: u8 = 0;
|
||||
const PROCESSSOR_UID: u8 = 1;
|
||||
|
||||
|
|
Loading…
Reference in a new issue