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

Allow for custom behaviours #6

Open
nathanielc opened this issue Feb 13, 2023 · 0 comments
Open

Allow for custom behaviours #6

nathanielc opened this issue Feb 13, 2023 · 0 comments

Comments

@nathanielc
Copy link

nathanielc commented Feb 13, 2023

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.

@dignifiedquire dignifiedquire transferred this issue from n0-computer/iroh Feb 17, 2023
fabricedesre added a commit to capyloon/beetle that referenced this issue Mar 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant