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

network/newstream: new stream! protocol base implementation #1500

Merged
merged 85 commits into from Jul 8, 2019
Merged

Conversation

acud
Copy link
Member

@acud acud commented Jun 20, 2019

This PR has originally set out to rewrite our existing pull syncer through a process of generalising and reiterating on the stream! protocol.

There has been a lot of work and examination of possible changes prior to the work done here. A lot of which has culminated into a preliminary spec with #1454.

This PR merges necessary changes to the wire protocol that were identified and deemed necessary while reimplementing the stream! protocol, as well as basic Peer data structure that will be needed to be used when incrementally introducing the protocol implementation, as well as the stream provider implementations (right now only sync stream).

The actual implementations have been removed from this PR and will be introduced in subsequent PRs to ease the diff and for the sake of clarity.

The files have been placed into network/newstream and the package named newstream, all until we can get rid of existing stream implementation and move in the new implementation into place.

related to:
#1451
ethersphere/user-stories#51

@acud acud added this to Backlog in Swarm Core - Sprint planning via automation Jun 20, 2019
@acud acud self-assigned this Jun 20, 2019
@acud acud force-pushed the new-syncer branch 3 times, most recently from f43129d to 6815d14 Compare June 20, 2019 10:31
@acud acud changed the title network/syncer: new pull sync implementation network/newstream: new stream protocol implementation Jul 5, 2019
@acud acud requested a review from nonsense July 5, 2019 11:52
@acud acud changed the title network/newstream: new stream protocol implementation network/newstream: new stream! protocol implementation Jul 5, 2019
@acud acud requested a review from zelig July 5, 2019 12:04
@acud acud moved this from Backlog to In review (includes Documentation) in Swarm Core - Sprint planning Jul 5, 2019
@acud acud changed the title network/newstream: new stream! protocol implementation network/newstream: new stream! protocol base implementation Jul 5, 2019
@acud acud marked this pull request as ready for review July 5, 2019 12:10
// You should have received a copy of the GNU Lesser General Public License
// along with the Swarm library. If not, see <http://www.gnu.org/licenses/>.

package newstream
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package is called newstream. Probably we should not be prefixing most of the structs in this package with Stream.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure i understand. existing stream directory will be removed. the package is not the same package. do you want the types to be prefixed with NewStream?

Copy link
Contributor

@nonsense nonsense Jul 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when your package is called stream or newstream, the types inside already have the context of the word / concept Stream, so no need to generally prefix them. For example newstream.StreamProvider -> newstream.Provider.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair enough 👍 I'll take care of it in the following iteration

}
return p
}
func (p *Peer) Left() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used at one place. Why not directly inline close(p.quit) there?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

var _ node.Service = (*SlipStream)(nil)
var (
pollTime = 1 * time.Second
createStreamsDelay = 50 * time.Millisecond //to avoid a race condition where we send a message to a server that hasnt set up yet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is createStreamsDelay really necessary? Can you give a concrete example of what you mean with we send a message to a server that hasnt set up yet?

@@ -0,0 +1,64 @@
// Copyright 2019 The Swarm Authors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a separate common_test file?

s.kad.On(np)
defer s.kad.Off(np)

sp := NewPeer(bp, s.intervalsStore, s.providers)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if sp contained all the handlers, and not peer, we wouldn't have to have such a weird structure where Peer is instantiated with pointers to providers and intervalsStore. A Peer should contain only what is relevant to a peer.

nonsense
nonsense previously approved these changes Jul 5, 2019
@acud acud merged commit af3b5e9 into master Jul 8, 2019
Swarm Core - Sprint planning automation moved this from In review (includes Documentation) to Done Jul 8, 2019
@skylenet skylenet deleted the new-syncer branch July 9, 2019 07:18
vojtechsimetka added a commit that referenced this pull request Jul 9, 2019
* master:
  network/newstream: new stream! protocol base implementation (#1500)
  swarm: fix bzz_info.port when using dynamic port allocation (#1537)
  cmd/swarm: make bzzaccount flag optional and add bzzkeyhex flag (#1531)
  cmd/swarm: remove separate function to parse env vars (#1536)
  network/bitvector: Multibit set/unset + string rep (#1530)
  swarm: 0.4.3 unstable (#1526)
  travis: also build on release tags (#1527)
  swarm: release v0.4.2 (#1496)
  network: bump bzz stream hive (#1522)
  docker: update ca-certificates file (#1525)
  Add swarm guide to /docs (#1513)
  network/simulation: Add ExecAdapter capability to swarm simulations (#1503)
chadsr added a commit to chadsr/swarm that referenced this pull request Sep 23, 2019
* 'master' of github.com:ethersphere/swarm: (54 commits)
  api, chunk, cmd, shed, storage: add support for pinning content (ethersphere#1509)
  docs/swarm-guide: cleanup (ethersphere#1620)
  travis: split jobs into different stages (ethersphere#1615)
  simulation: retry if we hit a collision on tcp/udp ports (ethersphere#1616)
  api, chunk: rename Tag.New to Tag.Create (ethersphere#1614)
  pss: instrumentation and refactor (ethersphere#1580)
  api, cmd, network: add --disable-auto-connect flag (ethersphere#1576)
  changelog: fix typo (ethersphere#1605)
  version: update to v0.4.4 unstable (ethersphere#1603)
  swarm: release v0.4.3 (ethersphere#1602)
  network/retrieve: add bzz-retrieve protocol (ethersphere#1589)
  PoC: Network simulation framework (ethersphere#1555)
  network: structured output for kademlia table (ethersphere#1586)
  client: add bzz client, update smoke tests (ethersphere#1582)
  swarm-smoke: fix check max prox hosts for pull/push sync modes (ethersphere#1578)
  cmd/swarm: allow using a network interface by name for nat purposes (ethersphere#1557)
  pss: disable TestForwardBasic (ethersphere#1544)
  api, network: count chunk deliveries per peer (ethersphere#1534)
  network/newstream: new stream! protocol base implementation (ethersphere#1500)
  swarm: fix bzz_info.port when using dynamic port allocation (ethersphere#1537)
  ...
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants