@@ -163,7 +163,7 @@ pub struct Client<Env: Environment> {
163163 tracked_chains : Arc < RwLock < HashSet < ChainId > > > ,
164164 /// References to clients waiting for chain notifications.
165165 notifier : Arc < ChannelNotifier < Notification > > ,
166- /// A reference to the Signer used to sign messages .
166+ /// A reference to the [` Signer`] used to sign block proposals .
167167 signer : Box < dyn Signer > ,
168168 /// Chain state for the managed chains.
169169 chains : DashMap < ChainId , ChainClientState > ,
@@ -232,7 +232,7 @@ impl<Env: Environment> Client<Env> {
232232 & self . local_node
233233 }
234234
235- /// Returns a reference to the `Signer`] of the client.
235+ /// Returns a reference to the [ `Signer`] of the client.
236236 #[ instrument( level = "trace" , skip( self ) ) ]
237237 pub fn signer ( & self ) -> & impl Signer {
238238 & self . signer
@@ -1120,38 +1120,32 @@ impl<Env: Environment> ChainClient<Env> {
11201120 . chain ( & manager. leader )
11211121 . any ( |owner| * owner == preferred_owner) ;
11221122
1123+ if !is_owner {
1124+ let accepted_owners = manager
1125+ . ownership
1126+ . all_owners ( )
1127+ . chain ( & manager. leader )
1128+ . collect :: < Vec < _ > > ( ) ;
1129+ warn ! ( %self . chain_id, ?accepted_owners, ?preferred_owner,
1130+ "Chain has multiple owners configured but none is preferred owner" ,
1131+ ) ;
1132+ return Err ( ChainClientError :: NotAnOwner ( self . chain_id ) ) ;
1133+ }
1134+
11231135 let has_signer = self
11241136 . signer ( )
11251137 . contains_key ( & preferred_owner)
11261138 . await
11271139 . map_err ( ChainClientError :: signer_failure) ?;
11281140
1129- if is_owner && has_signer {
1130- Ok ( preferred_owner)
1131- } else {
1132- if !is_owner {
1133- let accepted_owners = manager
1134- . ownership
1135- . all_owners ( )
1136- . chain ( & manager. leader )
1137- . collect :: < Vec < _ > > ( ) ;
1138- warn ! ( %self . chain_id, ?accepted_owners, ?preferred_owner,
1139- "Chain has multiple owners configured but none is preferred owner" ,
1140- ) ;
1141- return Err ( ChainClientError :: NotAnOwner ( self . chain_id ) ) ;
1142- }
1143-
1144- if !has_signer {
1145- warn ! ( %self . chain_id, ?preferred_owner,
1146- "Chain is one of the owners but its Signer instance doesn't contain the key" ,
1147- ) ;
1148- return Err ( ChainClientError :: CannotFindKeyForChain ( self . chain_id ) ) ;
1149- }
1150- unreachable ! (
1151- "Either is_owner and has_signer are both true,
1152- or one of them if false - all three cases are covered."
1141+ if !has_signer {
1142+ warn ! ( %self . chain_id, ?preferred_owner,
1143+ "Chain is one of the owners but its Signer instance doesn't contain the key" ,
11531144 ) ;
1145+ return Err ( ChainClientError :: CannotFindKeyForChain ( self . chain_id ) ) ;
11541146 }
1147+
1148+ Ok ( preferred_owner)
11551149 }
11561150
11571151 /// Obtains the public key associated to the current identity.
0 commit comments