-
Notifications
You must be signed in to change notification settings - Fork 58
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
feat(client): implement ClientOperationCfg to control any client oper… #2657
base: main
Are you sure you want to change the base?
Conversation
9be3586
to
33b97f4
Compare
30e7793
to
1b159fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work! Couple of areas where I have doubts and questions.
// loud mode: print a celebratory message to console | ||
#[cfg(feature = "loud")] | ||
{ | ||
println!("🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟 RECEIVED REWARD 🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟"); | ||
println!( | ||
"Total payment of {reward_amount:?} atto tokens accepted for record {pretty_key}" | ||
); | ||
println!("🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟"); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait this is useful, please keep it
if json { | ||
download_output.print_json(); | ||
} else { | ||
download_output.print(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't this be part of client config so we don't need to carry around a json bool?
@@ -23,7 +23,6 @@ name = "put_and_dir_upload" | |||
default = [] | |||
external-signer = ["ant-evm/external-signer"] | |||
extension-module = ["pyo3/extension-module"] | |||
loud = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feature is very useful for local testing for us, I think we should keep it around. Most users will never us it but that's fine, it's off by default.
#[cfg(feature = "loud")] | ||
println!( | ||
"Uploading public archive referencing {} files", | ||
archive.map().len() | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I agree it's not the prettiest way to do it, it's an excellent UX for CLI. Until we find another way I think we need to keep it
#[cfg(feature = "loud")] | ||
println!("Upload completed in {:?}", start.elapsed()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
#[cfg(feature = "loud")] | ||
println!("Uploading file: {path:?}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
.expect("receiver should not close"); | ||
.expect("Could not send TimedOutWithIncompatibleProtocol, receiver should not close"); | ||
} else { | ||
sender | ||
.send(Err(ConnectError::TimedOut)) | ||
.expect("receiver should not close"); | ||
.expect("Could not send TimedOut, receiver should not close"); | ||
} | ||
} | ||
} | ||
event = event_receiver.recv() => { | ||
let event = event.expect("receiver should not close"); | ||
let event = event.expect("Could not receiver Network event, receiver should not close"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although this originates not in this PR, I suggest we BAN expect
altogether as they do fail sometimes!
@@ -27,7 +27,7 @@ ant-bootstrap = { path = "../ant-bootstrap", version = "0.1.4" } | |||
ant-build-info = { path = "../ant-build-info", version = "0.1.23" } | |||
ant-logging = { path = "../ant-logging", version = "0.2.45" } | |||
ant-protocol = { path = "../ant-protocol", version = "0.3.3" } | |||
autonomi = { path = "../autonomi", version = "0.3.5", features = [ "loud" ] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feature although I agree not the most elegant way to do it, made the UX great. Removing it will result in a frustrating user experience while waiting for uploads.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also not a proponent of removing this. Users on the forum are already showing a lack of understanding what's happening when using the CLI.
#[cfg(feature = "loud")] | ||
println!("Estimated network size: {estimated_network_size:?}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This too is very useful for local tests
#[cfg(feature = "loud")] | ||
println!("New peer added to routing table: {added_peer:?}, now we have #{n_peers} connected peers"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This too
ant-networking/src/event/swarm.rs
Outdated
#[cfg(feature = "loud")] | ||
{ | ||
println!("Multiaddr not supported : {addr:?}"); | ||
println!("If this was your bootstrap peer, restart your node with a supported multiaddr"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This as well
@@ -27,7 +27,7 @@ ant-bootstrap = { path = "../ant-bootstrap", version = "0.1.4" } | |||
ant-build-info = { path = "../ant-build-info", version = "0.1.23" } | |||
ant-logging = { path = "../ant-logging", version = "0.2.45" } | |||
ant-protocol = { path = "../ant-protocol", version = "0.3.3" } | |||
autonomi = { path = "../autonomi", version = "0.3.5", features = [ "loud" ] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also not a proponent of removing this. Users on the forum are already showing a lack of understanding what's happening when using the CLI.
.await | ||
.wrap_err("Failed to fetch data from address")?; | ||
.map_err(|err| { | ||
error!("Failed to fetch archive from address: {private_address:?}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use inspect_err
to report errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually map the error to a different type here, so it should be fine for the logging to go in here I think.
std::fs::write(path, bytes)?; | ||
progress_bar.clone().inc(1); | ||
std::fs::create_dir_all(parent).map_err(|err| { | ||
error!("Failed to create parent directories for {path:?}: {err}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use inspect_err
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, we actually map the error to a different type here, so it should be fine for the logging to go in here.
(err.into(), all_errs.clone()) | ||
})?; | ||
std::fs::write(&path, bytes).map_err(|err| { | ||
error!("Failed to write file {path:?}: {err}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use inspect_err
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
.wrap_err("Failed to fetch data from address")?; | ||
) -> Result<(), (DownloadError, Vec<(String, String)>)> { | ||
let archive = client.archive_get_public(address).await.map_err(|err| { | ||
error!("Failed to fetch archive from address: {address:?}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use inspect_err
.
std::fs::write(path, bytes)?; | ||
progress_bar.clone().inc(1); | ||
std::fs::create_dir_all(parent).map_err(|err| { | ||
error!("Failed to create parent directories for {path:?}: {err}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use inspect_err
.
(err.into(), all_errs.clone()) | ||
})?; | ||
std::fs::write(&path, bytes).map_err(|err| { | ||
error!("Failed to write file {path:?}: {err}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use inspect_err.
b87c63a
to
5231a91
Compare
No description provided.