Skip to content

feat!: Make blobs more cheaply cloneable by by giving it an Inner #30

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

Closed
wants to merge 3 commits into from

Conversation

rklaehn
Copy link
Collaborator

@rklaehn rklaehn commented Dec 6, 2024

Description

Make blobs more cheaply cloneable by by giving it an Inner

Instead of having lots of Arcs in Blobs, introduce a BlobsInner and arc the whole thing. This makes cloning Blobs much cheaper and also simplifies the code a bit.

Also remove the lazily initialized rpc client/rpc handler pair and instead provide a fn to return that handler for the API user to store somewhere.

Breaking Changes

Notes & open questions

How should the fn be called that returns the rpc handler. Probably best to rename it since just changing .client() to return an owned thing instead of a borrowed thing would result in people using it in a wrong way (create it on demand on each call, for example).

create_client()?
create_handler()?

Likewise we now need a name for the thing that is returned. People want to store it somewhere, so it can't just be an impl Deref.

Change checklist

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant.
  • All breaking changes documented.

Copy link

github-actions bot commented Dec 6, 2024

Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh-blobs/pr/30/docs/iroh_blobs/

Last updated: 2024-12-06T09:54:35Z

The lazy handler kept a reference to Blobs alive. This caused both the
task and the blobs to never be dropped. To solve this you can just split
the inner part in 2 parts, one that has the handle and one that has the
logic. But that is not nice. I think it is best for the mem rpc handler
to exist completely separately, especially given that rpc is a non-default
feature.
…need to put away somewhere.

Or maybe spawn_client?
@rklaehn rklaehn closed this Dec 6, 2024
@rklaehn rklaehn deleted the dont-be-lazy branch January 2, 2025 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants