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

feat: offline adding #415

Merged
merged 2 commits into from
Oct 25, 2022
Merged

feat: offline adding #415

merged 2 commits into from
Oct 25, 2022

Conversation

b5
Copy link
Member

@b5 b5 commented Oct 25, 2022

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

@b5 b5 added the c-ctl label Oct 25, 2022
@b5 b5 self-assigned this Oct 25, 2022
@b5 b5 requested a review from Arqu October 25, 2022 15:08
rklaehn
rklaehn previously approved these changes Oct 25, 2022
Copy link
Contributor

@rklaehn rklaehn left a 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()) {
Copy link
Contributor

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{}",
Copy link
Contributor

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.

https://docs.rs/anyhow/latest/anyhow/macro.bail.html

/// services for additional scrutiny
pub async fn require_services(
api: &impl Api,
services: HashSet<&str>,
Copy link
Contributor

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.

Copy link
Member Author

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,
Copy link
Contributor

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

@b5 b5 changed the title allow offline adding feat: offline adding Oct 25, 2022
@b5 b5 added this to the v0.1.0 milestone Oct 25, 2022
@b5 b5 merged commit 7725508 into main Oct 25, 2022
@Arqu Arqu deleted the b5/offline_add branch October 25, 2022 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants