(
mut self,
mut syncer: SyncerMailbox<S, Block>,
mut finalizer: FinalizerMailbox<S, Block>,
)
| 99 | P: PublicKey, |
| 100 | K: Signer, |
| 101 | V: Variant, |
| 102 | ES: Epocher, |
| 103 | > Actor<R, C, S, P, K, V, ES> |
| 104 | { |
| 105 | pub async fn new(context: R, cfg: ApplicationConfig<C, ES>) -> (Self, Mailbox<P>) { |
| 106 | let (tx, rx) = mpsc::channel(cfg.mailbox_size); |
| 107 | |
| 108 | let genesis_hash = cfg.genesis_hash; |
| 109 | |
| 110 | ( |
| 111 | Self { |
| 112 | context: ContextCell::new(context), |
| 113 | mailbox: rx, |
| 114 | engine_client: cfg.engine_client, |
| 115 | genesis_hash, |
| 116 | max_message_size_bytes: cfg.max_message_size_bytes, |
| 117 | epocher: cfg.epocher, |
| 118 | cancellation_token: cfg.cancellation_token, |
| 119 | leader_timeout: cfg.leader_timeout, |
| 120 | #[cfg(feature = "permissioned")] |
| 121 | paused: cfg.paused, |
| 122 | _scheme_marker: PhantomData, |
| 123 | _key_marker: PhantomData, |
| 124 | _signer_marker: PhantomData, |
| 125 | _variant_marker: PhantomData, |
| 126 | }, |
| 127 | Mailbox::new(tx), |
| 128 | ) |
| 129 | } |
| 130 | |
| 131 | pub fn start( |
| 132 | mut self, |
| 133 | syncer: SyncerMailbox<S, Block>, |
| 134 | finalizer: FinalizerMailbox<S, Block>, |
| 135 | ) -> Handle<()> { |
| 136 | spawn_cell!(self.context, self.run(syncer, finalizer)) |
| 137 | } |
| 138 | |
| 139 | pub async fn run( |
| 140 | mut self, |
| 141 | mut syncer: SyncerMailbox<S, Block>, |
| 142 | mut finalizer: FinalizerMailbox<S, Block>, |
| 143 | ) { |
| 144 | let rand_id: u8 = rand::random(); |
| 145 | let mut signal = self.context.stopped().fuse(); |
| 146 | let cancellation_token = self.cancellation_token.clone(); |
| 147 | loop { |
| 148 | select! { |
| 149 | message = self.mailbox.recv() => { |
| 150 | let Some(message) = message else { |
| 151 | break; |
| 152 | }; |
| 153 | match message { |
| 154 | Message::Genesis { response, epoch } => { |
| 155 | if epoch.get() == 0 { |
| 156 | let _ = response.send(self.genesis_hash.into()); |
| 157 | } else { |
| 158 | let epoch_genesis_hash = finalizer |
nothing calls this directly
no outgoing calls
no test coverage detected