Skip to content
This repository was archived by the owner on Dec 18, 2023. It is now read-only.
This repository was archived by the owner on Dec 18, 2023. It is now read-only.

Allow for custom behaviours #6

@nathanielc

Description

@nathanielc

It would be valuable to add custom behaviours to the embedded mode of iroh. We (ceramic network) are exploring embedding iroh into a Rust implementation of our Ceramic node. Having the ability to write our own protocols (aka behaviours) will enable us to leverage iroh's features while customizing it for our own network needs as well.

Design

By design, behaviours are meant to be composable. Therefore it makes the most since to extend iroh's network logic via behaviours. The goals of a change would be:

  • have the ability to compose custom behaviours with the existing NodeBehaviour,
  • have the ability to handle behaviour events in hosting application.

The second point is a bit vague and I will likely need to explore it more before understanding exactly what hosting applications would need from their custom behaviours.

Implementation Ideas

I took a look at the code and I have a rough plan for how we could accomplish this feature.

  • Make the existing behaviour parameterized by an additional custom behaviour, i.e. NodeBehaviour<B: NetworkBehaviour>
  • Add custom_behaviour field to existing behaviour via a Toggle behaviour. i.e. custom_behaviour: Toggle<B>
  • Plumb adding a custom behaviour out through the IrohBuilder API so consumers can specify their custom behaviour. Should be possible to do this in a backward compatible way such that only new code wishing to use this feature needs to update to consume these new APIs.

Those are my ideas, I am willing to submit a PR for this work (in fact I have a hacky version working already), however I wanted to discuss first before dropping a PR that changes lots of API surface area.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions