paritytech / paritytech/litep2p

substreams: Allow substreams to close without consuming self

Open
#331 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
161
Forks
38
Avg merge
13h 43m
Merged PRs (30d)
12

Description

The current implementation consumes self when calling the close method on the substream.
After the close is called, the substream's end user should no longer write data into it.
This is a bit restrictive because the substream can be drained/read after the close call.

https://github.com/paritytech/litep2p/blob/2a49fd0acfa767183f5a6f3b5c116e0c653e6252/src/substream/mod.rs#L339

It is entirely possible to have the following scenario:

  • Write data to the substream
  • Substream close (signals the receiver end via read bytes number = 0)
  • Read data from the substream

One such implementation is the /perf/1.0.0 protocol from rust-libp2p.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/substream/mod.rs around line 339 and inspect the substream close method and its read/drain lifecycle. Reproduce the sequence of writing data, closing the substream, and then reading it. Done means close signals the receiver while still allowing already-written data to be drained afterward.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
networking
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.