Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.18: [anza migration] Sets client id to Agave (backport of #163) #206

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions version/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum ClientId {
SolanaLabs,
JitoLabs,
Firedancer,
Agave,
// If new variants are added, update From<u16> and TryFrom<ClientId>.
Unknown(u16),
}
Expand Down Expand Up @@ -63,7 +64,7 @@ impl Default for Version {
commit: compute_commit(option_env!("CI_COMMIT")).unwrap_or_default(),
feature_set,
// Other client implementations need to modify this line.
client: u16::try_from(ClientId::SolanaLabs).unwrap(),
client: u16::try_from(ClientId::Agave).unwrap(),
}
}
}
Expand Down Expand Up @@ -97,6 +98,7 @@ impl From<u16> for ClientId {
0u16 => Self::SolanaLabs,
1u16 => Self::JitoLabs,
2u16 => Self::Firedancer,
3u16 => Self::Agave,
_ => Self::Unknown(client),
}
}
Expand All @@ -110,7 +112,8 @@ impl TryFrom<ClientId> for u16 {
ClientId::SolanaLabs => Ok(0u16),
ClientId::JitoLabs => Ok(1u16),
ClientId::Firedancer => Ok(2u16),
ClientId::Unknown(client @ 0u16..=2u16) => Err(format!("Invalid client: {client}")),
ClientId::Agave => Ok(3u16),
ClientId::Unknown(client @ 0u16..=3u16) => Err(format!("Invalid client: {client}")),
ClientId::Unknown(client) => Ok(client),
}
}
Expand Down Expand Up @@ -147,19 +150,21 @@ mod test {
assert_eq!(ClientId::from(0u16), ClientId::SolanaLabs);
assert_eq!(ClientId::from(1u16), ClientId::JitoLabs);
assert_eq!(ClientId::from(2u16), ClientId::Firedancer);
for client in 3u16..=u16::MAX {
assert_eq!(ClientId::from(3u16), ClientId::Agave);
for client in 4u16..=u16::MAX {
assert_eq!(ClientId::from(client), ClientId::Unknown(client));
}
assert_eq!(u16::try_from(ClientId::SolanaLabs), Ok(0u16));
assert_eq!(u16::try_from(ClientId::JitoLabs), Ok(1u16));
assert_eq!(u16::try_from(ClientId::Firedancer), Ok(2u16));
for client in 0..=2u16 {
assert_eq!(u16::try_from(ClientId::Agave), Ok(3u16));
for client in 0..=3u16 {
assert_eq!(
u16::try_from(ClientId::Unknown(client)),
Err(format!("Invalid client: {client}"))
);
}
for client in 3u16..=u16::MAX {
for client in 4u16..=u16::MAX {
assert_eq!(u16::try_from(ClientId::Unknown(client)), Ok(client));
}
}
Expand Down
Loading