- Replication is a push-only protocol:
- Alice sends message to Bob
- Bob reads the message, does not reply to Alice
- The spec mentions 1 stream per peer connection, which will work because of the push-only nature of the protocol
- Currently the implementation uses at most 2 streams per connection:
- Consider 2 peers: Alice & Bob
- Alice wants to push out a message (ie. Alice→Bob) so she opens an outbound stream, the stream is bidirectional but one direction is used (Bob → Alice direction is not utilized, Bob does not respond over the same stream)
- Alice also wants to get replication messages from other peers, so she accepts any inbound streams opened by other peers. When Alice reads a message pushed out by Bob, only one direction in the bidirectional stream is utilized (Bob → Alice), as Alice does not reply to the message.
- In result there’s 2 half-utilized libp2p streams that are complementary
- We could consider optimizing stream usage and just use 1 libp2p stream which would be split into R & W halves