diff --git a/rpc/service/src/service.rs b/rpc/service/src/service.rs index d54d11d43..16e1b3ea7 100644 --- a/rpc/service/src/service.rs +++ b/rpc/service/src/service.rs @@ -553,7 +553,7 @@ impl RpcApi for RpcCoreService { (curr_daa_score - header.daa_score).checked_mul(1000).unwrap_or(u64::MAX) } else { // "next" header is the one that we processed last iteration - let next_header = headers.get(header_idx - 1).unwrap(); + let next_header = &headers[header_idx - 1]; let time_between_now_and_next = next_header.timestamp - header.timestamp; let score_between_now_and_request = curr_daa_score - header.daa_score; let score_between_now_and_next = next_header.daa_score - header.daa_score; @@ -575,11 +575,7 @@ impl RpcApi for RpcCoreService { } } - let mut timestamps = Vec::::new(); - - for curr_daa_score in request.daa_scores { - timestamps.push(daa_score_timestamp_map[&curr_daa_score]); - } + let timestamps = request.daa_scores.iter().map(|curr_daa_score| daa_score_timestamp_map[curr_daa_score]).collect(); Ok(GetDaaScoreTimestampEstimateResponse::new(timestamps)) }