This repository was archived by the owner on Aug 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 110
swarm/network/stream: use bzzAddr for proximity calculation #1360
Closed
holisticode
wants to merge
2
commits into
swarm-rather-stable-update-syncing
from
swarm-rather-stable-update-syncing-bzzAddr
Closed
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,6 +58,7 @@ var ErrMaxPeerServers = errors.New("max peer servers") | |
| // Peer is the Peer extension for the streaming protocol | ||
| type Peer struct { | ||
| *protocols.Peer | ||
| bzzPeer *network.BzzPeer | ||
| streamer *Registry | ||
| pq *pq.PriorityQueue | ||
| serverMu sync.RWMutex | ||
|
|
@@ -77,9 +78,10 @@ type WrappedPriorityMsg struct { | |
| } | ||
|
|
||
| // NewPeer is the constructor for Peer | ||
| func NewPeer(peer *protocols.Peer, streamer *Registry) *Peer { | ||
| func NewPeer(peer *network.BzzPeer, streamer *Registry) *Peer { | ||
| p := &Peer{ | ||
| Peer: peer, | ||
| Peer: peer.Peer, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Explicitly keeping a pointer to peer.Peer seems redundant.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above |
||
| bzzPeer: peer, | ||
| pq: pq.New(int(PriorityQueue), PriorityQueueCap), | ||
| streamer: streamer, | ||
| servers: make(map[Stream]*server), | ||
|
|
@@ -440,7 +442,7 @@ func (p *Peer) runUpdateSyncing() { | |
| } | ||
|
|
||
| kad := p.streamer.delivery.kad | ||
| po := chunk.Proximity(network.NewAddr(p.Node()).Over(), kad.BaseAddr()) | ||
| po := chunk.Proximity(p.bzzPeer.Over(), kad.BaseAddr()) | ||
|
|
||
| depth := kad.NeighbourhoodDepth() | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
bzzPeerhas access to theprotocols.Peer, so maybe we don't need the embedding on line 60 ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I applied a change to address this which resulted in quite a lot of cascading changes...I hope this does not introduce some new level of "ugliness"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@holisticode all the
peerstructs are confusing to me. I suggested the change in case it didn't result in many cascading changes. If this is not the case, feel free to just address this particular problem, and once this is correct, we can review and discuss how to refactor :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@holisticode I am sorry if you have understood my comment as a request to do that change - it was not intended as such.
I think the new cascading change is much worse to what we have right now, and will also result in many conflicts with other branches we have in progress right now.
Furthermore this cascading change is not addressing the underlying problem - which is the mess of all the different
peerstructs and their inheritance.I suggest we just fix the proximity calculations if possible, and not do such cascading change throughout the codebase, unless we actually address the underlying problem of the design.