File tree Expand file tree Collapse file tree 2 files changed +11
-12
lines changed Expand file tree Collapse file tree 2 files changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -232,13 +232,13 @@ impl SpecValidators {
232
232
}
233
233
}
234
234
235
- pub fn find_index ( & self , validator_id : & ValidatorId ) -> i32 {
235
+ pub fn find_index ( & self , validator_id : & ValidatorId ) -> Option < i32 > {
236
236
if & self . leader ( ) . id == validator_id {
237
- 0
237
+ Some ( 0 )
238
238
} else if & self . follower ( ) . id == validator_id {
239
- 1
239
+ Some ( 1 )
240
240
} else {
241
- - 1
241
+ None
242
242
}
243
243
}
244
244
Original file line number Diff line number Diff line change @@ -254,16 +254,15 @@ pub async fn create_validator_messages<A: Adapter + 'static>(
254
254
. await ?;
255
255
256
256
if channel_is_exhausted {
257
- // can never be -1
258
- let validator_index = channel . spec . validators . find_index ( & session . uid ) ;
259
- update_exhausted_channel (
260
- & app . pool ,
261
- & channel ,
262
- validator_index
263
- ) . await ? ;
257
+ if let Some ( validator_index ) = channel . spec . validators . find_index ( & session . uid ) {
258
+ update_exhausted_channel (
259
+ & app . pool ,
260
+ & channel ,
261
+ validator_index
262
+ ) . await ? ;
263
+ }
264
264
}
265
265
266
-
267
266
Ok ( success_response ( serde_json:: to_string ( & SuccessResponse {
268
267
success : true ,
269
268
} ) ?) )
You can’t perform that action at this time.
0 commit comments