-
Notifications
You must be signed in to change notification settings - Fork 185
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: offline adding #415
feat: offline adding #415
Conversation
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.
Looks good, except for the return Err(anyhow!
.
// we require p2p for adding right now because we don't have a mechanism for | ||
// hydrating only the root CID to the p2p node for providing if a CID were | ||
// ingested offline. Offline adding should happen, but this is the current | ||
// path of least confusion | ||
require_services(api, HashSet::from(["store", "p2p"])).await?; | ||
let svc_status = require_services(api, HashSet::from(["store"])).await?; | ||
match (provide, svc_status.p2p.status()) { |
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.
Not for this PR, but we have to make sure that we refuse to speak to services with different build version
iroh/src/run.rs
Outdated
(true, ServiceStatus::Unknown) | ||
| (true, ServiceStatus::NotServing) | ||
| (true, ServiceStatus::ServiceUnknown) => { | ||
return Err(anyhow!("Add provides content to the IPFS network by default, but the p2p service is not running.\n{}", |
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.
There is anyhow::bail! which does this and maybe looks a bit nicer.
/// services for additional scrutiny | ||
pub async fn require_services( | ||
api: &impl Api, | ||
services: HashSet<&str>, |
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.
I would prefer BTreeSet in such cases because it is more deterministic. But in this case it does not really matter.
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.
yeah totally. I'll come through & refactor all uses of HashSet
to BTreeSet
in a follow up
path: &Path, | ||
no_wrap: bool, | ||
recursive: bool, | ||
provide: bool, |
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.
the next person touching this needs to create a config struct
I have no idea what this does for our provide story if a user adds content offline then tries to take it online, but this makes our perf measurable.
I still think we should provide the root to the DHT by default. It's usually what users are trying to do, and while it's slower, it's the de-facto use case