Skip to content

Commit

Permalink
Send if registrations vector is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelBilbao committed Jan 20, 2025
1 parent 06d0ba0 commit 45d7e49
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion crates/common/src/config/pbs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub struct RelayConfig {
pub frequency_get_header_ms: Option<u64>,
/// Maximum number of validators to send to relays in one registration
/// request
#[serde(deserialize_with = "empty_string_as_none")]
#[serde(deserialize_with = "empty_string_as_none", default)]
pub validator_registration_batch_size: Option<usize>,
}

Expand Down
26 changes: 20 additions & 6 deletions crates/pbs/src/mev_boost/register_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,34 @@ pub async fn register_validator<S: BuilderApiState>(
let relays = state.all_relays().to_vec();
let mut handles = Vec::with_capacity(relays.len());
for relay in relays.clone() {
for batch in registrations
.chunks(relay.config.validator_registration_batch_size.unwrap_or(registrations.len()))
.map(|chunk| chunk.to_vec())
.collect::<Vec<Vec<ValidatorRegistration>>>()
{
if registrations.is_empty() {
handles.push(tokio::spawn(
send_register_validator_with_timeout(
batch,
vec![],
relay.clone(),
send_headers.clone(),
state.pbs_config().timeout_register_validator_ms,
)
.in_current_span(),
));
} else {
for batch in registrations
.chunks(
relay.config.validator_registration_batch_size.unwrap_or(registrations.len()),
)
.map(|chunk| chunk.to_vec())
.collect::<Vec<Vec<ValidatorRegistration>>>()
{
handles.push(tokio::spawn(
send_register_validator_with_timeout(
batch,
relay.clone(),
send_headers.clone(),
state.pbs_config().timeout_register_validator_ms,
)
.in_current_span(),
));
}
}
}

Expand Down

0 comments on commit 45d7e49

Please sign in to comment.