n0-computer / iroh-ffi

FFI bindings for iroh
https://iroh.computer
18 stars 7 forks source link

Allow connecting to an existing node instead of start a new one #94

Open hadim opened 8 months ago

hadim commented 8 months ago

My use case is for the Python binding but I guess it could be useful for other bindings as well.

Discord chat: https://discord.com/channels/1161119546170687619/1161119546644627528/1199697069686931508

hadim commented 8 months ago

Happy to give it a shot with some help/guidance.

dignifiedquire commented 8 months ago

The basic structure would be to allow the IrohNode (https://github.com/n0-computer/iroh-ffi/blob/main/src/node.rs#L185) be either a full node, or a client connection, established like here: https://github.com/n0-computer/iroh/blob/main/iroh/src/commands.rs#L148

eg change node: Node<iroh::bytes::store::flat::Store>, to be

enum InnerNode {
  Full(Node<iroh::bytes::store::flat::Store>),
  Client(iroh::client::quic::Iroh),
}
hadim commented 8 months ago

I gave it a quick shot, but iroh_quic_connect is not exported. I tried to export it by tweaking the iroh repo, but I am running into a bunch of error in cascades when editing lib.rs with pub mod and pub use.