Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ipfs/go-bitswap] Connection State Tracking #95

Open
Stebalien opened this issue Apr 22, 2020 · 0 comments
Open

[ipfs/go-bitswap] Connection State Tracking #95

Stebalien opened this issue Apr 22, 2020 · 0 comments

Comments

@Stebalien
Copy link
Member

Currently, we handle enqueuing broadcast wants synchronously when we process "connect" events. Instead, we should do the minimal amount of work possible when processing events, handing broadcast wants in the background.

General Design

There are two parts to this design:

  1. Connectivity tracking: reference count connections to keep track of whether or not we're connected to a peer.
  2. Availability tracking: records whether or not the peer is available as a bitswap peer.

States

  • Disconnected (has no connections)
  • Connected (has at least one connection)
  • Available

Transitions

  • disconnected -> connected
    • When:
      • We receive the first connection
    • Effect:
      • Start reference counting.
    • -> disconnected
    • When:
      • We drop the last connection.
    • Effect:
      • Forget the peer.
  • connected -> available
    • When:
      • We receive a "connect" event, check the peerstore, and see that the peer speaks the bitswap protocol.
      • We receive an identify event, see that the peer is connected and that the peer speaks the bitswap protocol.
      • We receive a bitswap message from the peer.
    • Effect:
      • Tell the PeerManager that the peer is available.
  • available -> connected
    • When:
      • The peer is marked unresponsive because we fail to send them a message.
    • Effect:
      • Drop the message queue for the peer.
      • Don't drop the ledger or anything else.

Ideas

I'm having trouble completely fleshing out this design so I'm going to write some other ideas:

  1. I'd have one goroutine for processing events, transitioning from disconnected, to connected, to available.
  2. I'd have one goroutine syncing the peer's state with the peer manager.

The important part is that if any subsystem signals that the peer should transition from available to connected, the peer must transition to connected, even if it ends up transitioning back to available.

I have some ideas on how to do this, but I'll have to try to write them up later.

@Jorropo Jorropo transferred this issue from ipfs/go-bitswap Jan 27, 2023
@Jorropo Jorropo changed the title Connection State Tracking [ipfs/go-bitswap] Connection State Tracking Jan 27, 2023
hacdias pushed a commit that referenced this issue Jan 30, 2023
on a tick, do not keep searching for providers for the same block. instead rely on a periodic search
for more providers. (which will run no matter what, even w/o ticks, to optimize found providers).
also backoff tick time to reduce broadcasts.

fix #95, fix #107


This commit was moved from ipfs/go-bitswap@49a96fb
guseggert pushed a commit that referenced this issue Mar 15, 2023
Jorropo pushed a commit that referenced this issue Mar 22, 2023
Implement API that allows iteration over multihashes and offsets in
`MultihasIndexSorted`. The API is specific to this index type;
therefore, the type is now exported along with its constructor funtion.

Write test that asserts `GetAll` and `ForEach` behave consistently.

Relates to #95


This commit was moved from ipld/go-car@1398bba
Jorropo pushed a commit to ipfs/go-libipfs-rapide that referenced this issue Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant