Skip to content

Any thoughts for wrapping a Swarm in an actix Actor? #3302

Closed Answered by elenaf9
raptros asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @raptros,
In a project that I used to work on we implemented an actix actor that managed our libp2p swarm.
However, we implemented the the Actor trait on top of an interface similar to the Client in the file-sharing example, instead of integrating that logic in the actor implementation itself. So an additional background task was still needed.

Like it is done in the file-sharing example, we polled the swarm in an event-loop in a background task. To execute commands on the swarm we had a mpsc channel to the event-loop. In your case, you could simply forward messages (that your actor receives) through this channel to the background task.

Additionally, the event-loop got passed an mpsc::S…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@raptros
Comment options

@thomaseizinger
Comment options

@raptros
Comment options

Answer selected by raptros
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants