solana-gossip spy can now specify a shred version (#10040)

This commit is contained in:
Michael Vines
2020-05-13 19:37:40 -07:00
committed by GitHub
parent c5460e7fee
commit 4e4a21f9b7
5 changed files with 42 additions and 17 deletions

View File

@@ -15,6 +15,13 @@ use std::process::exit;
fn main() -> Result<(), Box<dyn error::Error>> {
solana_logger::setup_with_default("solana=info");
let shred_version_arg = Arg::with_name("shred_version")
.long("shred-version")
.value_name("VERSION")
.takes_value(true)
.default_value("0")
.help("Filter gossip nodes by this shred version");
let matches = App::new(crate_name!())
.about(crate_description!())
.version(solana_version::version!())
@@ -53,6 +60,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
.default_value("5")
.help("Timeout in seconds"),
)
.arg(&shred_version_arg)
.setting(AppSettings::DisableVersion),
)
.subcommand(
@@ -110,6 +118,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
.validator(is_pubkey)
.help("Public key of a specific node to wait for"),
)
.arg(&shred_version_arg)
.arg(
Arg::with_name("timeout")
.long("timeout")
@@ -167,6 +176,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
let pubkey = matches
.value_of("node_pubkey")
.map(|pubkey_str| pubkey_str.parse::<Pubkey>().unwrap());
let shred_version = value_t_or_exit!(matches, "shred_version", u16);
let entrypoint_addr = parse_entrypoint(&matches);
@@ -212,6 +222,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
pubkey,
None,
Some(&gossip_addr),
shred_version,
)?;
if timeout.is_some() {
@@ -251,6 +262,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
let all = matches.is_present("all");
let entrypoint_addr = parse_entrypoint(&matches);
let timeout = value_t_or_exit!(matches, "timeout", u64);
let shred_version = value_t_or_exit!(matches, "shred_version", u16);
let (_all_peers, validators, _archivers) = discover(
entrypoint_addr.as_ref(),
Some(1),
@@ -258,6 +270,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
None,
entrypoint_addr.as_ref(),
None,
shred_version,
)?;
let rpc_addrs: Vec<_> = validators
@@ -298,6 +311,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
Some(pubkey),
None,
None,
0,
)?;
let validator = validators.iter().find(|x| x.id == pubkey).unwrap();