22
33use std:: sync:: Arc ;
44
5- use anyhow:: { Context , Result } ;
5+ use anyhow:: { Context , Result , bail } ;
66use espresso_types:: { PubKey , SeqTypes } ;
77use hotshot:: types:: Message ;
88use hotshot_types:: {
@@ -11,7 +11,7 @@ use hotshot_types::{
1111} ;
1212use request_response:: network:: Bytes ;
1313use serde:: { Deserialize , Serialize } ;
14- use tokio:: sync:: mpsc:: { Receiver , Sender } ;
14+ use tokio:: sync:: mpsc:: { Receiver , Sender , error :: TrySendError } ;
1515use vbs:: { BinarySerializer , bincode_serializer:: BincodeSerializer , version:: StaticVersion } ;
1616
1717use crate :: context:: TaskList ;
@@ -69,13 +69,16 @@ impl ExternalEventHandler {
6969 // Match the type
7070 match external_message {
7171 ExternalMessage :: RequestResponse ( request_response) => {
72- // Send the inner message to the request-response protocol
73- self . request_response_sender
74- . send ( request_response. into ( ) )
75- . await ?;
72+ match self
73+ . request_response_sender
74+ . try_send ( request_response. into ( ) )
75+ {
76+ Ok ( ( ) ) => Ok ( ( ) ) ,
77+ Err ( TrySendError :: Full ( ..) ) => bail ! ( "request-response channel full" ) ,
78+ Err ( TrySendError :: Closed ( ..) ) => bail ! ( "request-response channel closed" ) ,
79+ }
7680 } ,
7781 }
78- Ok ( ( ) )
7982 }
8083
8184 /// The main loop for sending outbound messages.
0 commit comments