NethermindEth / dotnet-libp2p

A libp2p implementation for .NET in C#.
MIT License
56 stars 21 forks source link

Improve channels implementation #8

Open flcl42 opened 1 year ago

flcl42 commented 1 year ago

Is your feature request related to a problem? Please describe. The current implementation is not optimal and does not implement backpush properly. It should be also reviewed for memory allocation efficiency and be covered by tests.

Describe the solution you'd like Implement pushback-enabled bidirectional channel that exposes an API for optimal buffer allocation and decreases coping while passing data between protocols.

Describe alternatives you've considered Standard Channels require the current API deep rethinking to integrate them, let's consider this option. Another approach is to define API that allows direct communication between protocol layers. https://learn.microsoft.com/en-us/dotnet/standard/io/pipelines?

Additional context Channels are used to pass data received from the network through the protocol stack. They are also used to control lifetime and signal about communication ending(which can be forced or regular).