Skip to content

Commit

Permalink
Code optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
coderofstuff committed Oct 7, 2023
1 parent f39380e commit 89a91b6
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions rpc/service/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -575,11 +575,7 @@ impl RpcApi for RpcCoreService {
}
}

let mut timestamps = Vec::<u64>::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))
}
Expand Down

0 comments on commit 89a91b6

Please sign in to comment.