Skip to content

Commit aa6c369

Browse files
committed
revert out-of-scope register_validator body-prep change
1 parent e6bc9c7 commit aa6c369

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

‎crates/pbs/src/mev_boost/register_validator.rs‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,17 @@ pub async fn register_validator<S: BuilderApiState>(
3535
.insert(HEADER_START_TIME_UNIX_MS, HeaderValue::from_str(&utcnow_ms().to_string())?);
3636
send_headers.insert(USER_AGENT, get_user_agent_with_version(&req_headers)?);
3737

38-
// prepare the body in advance
39-
let bodies: Vec<(usize, Bytes)> =
38+
// prepare the body in advance, ugly dyn
39+
let bodies: Box<dyn Iterator<Item = (usize, Bytes)>> =
4040
if let Some(batch_size) = state.config.pbs_config.validator_registration_batch_size {
41-
registrations
42-
.chunks(batch_size)
43-
.map(|batch| {
44-
let body = serde_json::to_vec(batch).map_err(PbsError::JsonEncode)?;
45-
Ok((batch.len(), Bytes::from(body)))
46-
})
47-
.collect::<Result<Vec<_>, PbsError>>()?
41+
Box::new(registrations.chunks(batch_size).map(|batch| {
42+
// SAFETY: unwrap is ok because we're serializing a &[serde_json::Value]
43+
let body = serde_json::to_vec(batch).unwrap();
44+
(batch.len(), Bytes::from(body))
45+
}))
4846
} else {
49-
let body = serde_json::to_vec(&registrations).map_err(PbsError::JsonEncode)?;
50-
vec![(registrations.len(), Bytes::from(body))]
47+
let body = serde_json::to_vec(&registrations).unwrap();
48+
Box::new(std::iter::once((registrations.len(), Bytes::from(body))))
5149
};
5250
send_headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
5351

0 commit comments

Comments
 (0)