Skip to content
This repository was archived by the owner on Aug 2, 2021. It is now read-only.
This repository was archived by the owner on Aug 2, 2021. It is now read-only.

simplify netstore / delivery / fetcher #1309

@nonsense

Description

@nonsense

Currently the code in:

  1. swarm/network/fetcher.go is very convoluted, due to tracking of outgoing chunk requests
  2. swarm/storage/netstore.go, fetcher struct is convoluted and obscures the API behind required params in context.Context, which change the control flow - namely source.
  3. Delivery and NetStore are coupled via the FetchFunc and context.Context.
  4. Fetcher and fetcher naming are very confusing.
  5. Fetcher contains a context as part of its struct.
  6. Tracing is mostly broken, apart from one or two traces (see SendPriority).

Because of this I propose:

  1. Most of this results in very difficult code to understand and trace. Some of the functionality can be replaced with https://godoc.org/golang.org/x/sync/singleflight and we can reduce complexity with it (swarm/network/fetcher.go).

  2. Reduce complexity for chunk requests across the network. Currently we have the following flow:

// doRequest attempts at finding a peer to request the chunk from
// * first it tries to request explicitly from peers that are known to have offered the chunk
// * if there are no such peers (available) it tries to request it from a peer closest to the chunk address
//   excluding those in the peersToSkip map
// * if no such peer is found an error is returned

I suggest we skip the first part for simplicity, and only add it if necessary.

  1. Decide on context cancelation across process boundary.

All of this will help with the numerous issues we have with Swarm being slow. Also related: #1148

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions