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: allow custom blob providing event handling #2583

Merged
merged 8 commits into from
Aug 13, 2024

Conversation

dignifiedquire
Copy link
Contributor

@dignifiedquire dignifiedquire commented Aug 2, 2024

Description

This adds the ability back to track blob provide events from an iroh node.

Breaking Changes

  • Modifies Event enum:
    • removes CustomGetRequestReceived
    • adds TransferProgress
  • send_blob now takes an EventSender
  • trait EventSender has been renamed CustomEventSender
  • the concrete (boxed) event sender is now called just EventSender

Notes & open questions

Notes:

I added progress events that get sent every single 16 KiB chunk. These events contain the usual data (connection id and request id) plus offset and hash. Adding the hash makes the event larger, but makes it very much self-contained.

The event is fired after the read, but that does not mean that the data has been successfully transferred. Should be good enough to show progress anyway.

These will be a lot of events, so they are sent using try_send in order not to slow down the transfer. That means that you might miss some events, but since they only contain the end_offset that should be fine.

Open questions:

I called the trait CustomEventSender and the concrete handle for an optional CustomEventSender just EventSender. I can revert this if somebody can think of a better name for the trait or the handle...

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 Aug 2, 2024

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

Last updated: 2024-08-13T09:25:48Z

iroh/src/node/builder.rs Outdated Show resolved Hide resolved
@dignifiedquire dignifiedquire added this to the v0.23.0 milestone Aug 8, 2024
# Conflicts:
#	iroh/src/client/blobs.rs
we still have a special case for no event sender so we don't pay the cost
for that if we don't need it.
@rklaehn rklaehn marked this pull request as ready for review August 13, 2024 08:58
Also take events by ref so we can avoid an arc clone. The SendingSliceReader
takes a mutable reference to the inner reader anyway, so it is not 'static.
Copy link
Contributor Author

@dignifiedquire dignifiedquire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@dignifiedquire dignifiedquire added this pull request to the merge queue Aug 13, 2024
Merged via the queue into main with commit bcc87a2 Aug 13, 2024
28 of 29 checks passed
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.

2 participants