Skip to content

Commit

Permalink
geyser: add hostname to version response (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
fanatid authored Mar 4, 2024
1 parent 24d18a7 commit 8ee6932
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The minor version will be incremented upon a breaking change and the patch versi
- proto: add `entries_count` to block meta message ([#283](https://github.com/rpcpool/yellowstone-grpc/pull/283))
- geyser: use `Vec::binary_search` instead of `HashSet::contains` in the filters ([#284](https://github.com/rpcpool/yellowstone-grpc/pull/284))
- proto: add `starting_transaction_index` to entry message ([#289](https://github.com/rpcpool/yellowstone-grpc/pull/289))
- geyser: add `hostname` to version response ([#291](https://github.com/rpcpool/yellowstone-grpc/pull/291))

### Breaking

Expand Down
18 changes: 18 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ git-version = "0.3.5"
google-cloud-googleapis = "0.11.0"
google-cloud-pubsub = "0.21.0"
hex = "0.4.3"
hostname = "0.3.1"
http = "0.2.8"
hyper = "0.14.27"
json5 = "0.4.1"
Expand Down
1 change: 1 addition & 0 deletions yellowstone-grpc-geyser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ bs58 = { workspace = true }
clap = { workspace = true, features = ["derive"] }
crossbeam-channel = { workspace = true }
futures = { workspace = true }
hostname = { workspace = true }
hyper = { workspace = true }
lazy_static = { workspace = true }
log = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions yellowstone-grpc-geyser/src/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use {
config::{ConfigBlockFailAction, ConfigGrpc},
filters::{Filter, FilterAccountsDataSlice},
prom::{self, CONNECTIONS_TOTAL, MESSAGE_QUEUE_SIZE},
version::VERSION,
version::GrpcVersionInfo,
},
log::{error, info},
solana_geyser_plugin_interface::geyser_plugin_interface::{
Expand Down Expand Up @@ -1398,7 +1398,7 @@ impl Geyser for GrpcService {
_request: Request<GetVersionRequest>,
) -> Result<Response<GetVersionResponse>, Status> {
Ok(Response::new(GetVersionResponse {
version: serde_json::to_string(&VERSION).unwrap(),
version: serde_json::to_string(&GrpcVersionInfo::default()).unwrap(),
}))
}
}
24 changes: 24 additions & 0 deletions yellowstone-grpc-geyser/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,27 @@ pub const VERSION: Version = Version {
rustc: env!("VERGEN_RUSTC_SEMVER"),
buildts: env!("VERGEN_BUILD_TIMESTAMP"),
};

#[derive(Debug, Serialize)]
pub struct GrpcVersionInfoExtra {
hostname: Option<String>,
}

#[derive(Debug, Serialize)]
pub struct GrpcVersionInfo {
version: Version,
extra: GrpcVersionInfoExtra,
}

impl Default for GrpcVersionInfo {
fn default() -> Self {
Self {
version: VERSION,
extra: GrpcVersionInfoExtra {
hostname: hostname::get()
.ok()
.and_then(|name| name.into_string().ok()),
},
}
}
}

0 comments on commit 8ee6932

Please sign in to comment.