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

swarm/network/stream: use bzzAddr for proximity calculation#1360

Closed
holisticode wants to merge 2 commits intoswarm-rather-stable-update-syncingfrom
swarm-rather-stable-update-syncing-bzzAddr
Closed

swarm/network/stream: use bzzAddr for proximity calculation#1360
holisticode wants to merge 2 commits intoswarm-rather-stable-update-syncingfrom
swarm-rather-stable-update-syncing-bzzAddr

Conversation

@holisticode
Copy link
Copy Markdown
Contributor

This PR uses BzzAddr instead of enode.ID to use chunk.Proximity() for po calculations between nodes.

This PR currently passes the tests but it is important to understand that it produces errors which do NOT result in the tests failing....check the logs!

// Peer is the Peer extension for the streaming protocol
type Peer struct {
*protocols.Peer
bzzPeer *network.BzzPeer
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The bzzPeer has access to the protocols.Peer, so maybe we don't need the embedding on line 60 ?

Copy link
Copy Markdown
Contributor Author

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"?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@holisticode all the peer structs 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 :)

Copy link
Copy Markdown
Contributor

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 peer structs 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.

Comment thread swarm/network/stream/peer.go Outdated
func NewPeer(peer *network.BzzPeer, streamer *Registry) *Peer {
p := &Peer{
Peer: peer,
Peer: peer.Peer,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Explicitly keeping a pointer to peer.Peer seems redundant.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

See above

var cancel func()
// TODO: do something with this hardcoded timeout, maybe use TTL in the future
ctx = context.WithValue(ctx, "peer", sp.ID().String())
ctx = context.WithValue(ctx, "peer", sp.bzzPeer.ID().String())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is changing behaviour on master. One of the things that I am addressing in simple-fetchers is the use of context as a container for values that change the logic of execution.

I am not sure if it is okay to change enode.ID to bzzAddr here.

// TODO: Enable this log line
// log.Warn("invalid chunk delivered", "peer", sp.ID(), "chunk", msg.Addr, )
msg.peer.Drop()
msg.peer.bzzPeer.Drop()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we have to change this? I think you are changing way too many places from peer to bzzPeer, which is essentially the same.

}

log.Trace("handle.chunk.delivery", "ref", msg.Addr, "from peer", sp.ID())
log.Trace("handle.chunk.delivery", "ref", msg.Addr, "from peer", sp.bzzPeer.ID())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is this necessary now, if we are not going to be refactoring all the peers in this PR?

// exchange between peers over p2p. Instead, error will be returned
// only if there is one from sending subscribe error message.
err = p.Send(ctx, SubscribeErrorMsg{
err = p.bzzPeer.Send(ctx, SubscribeErrorMsg{
Copy link
Copy Markdown
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 to change this as well? Whether we call Send on p or bzzPeer is the same, no?

@holisticode
Copy link
Copy Markdown
Contributor Author

Obsolete due to #1336

@nonsense nonsense deleted the swarm-rather-stable-update-syncing-bzzAddr branch June 5, 2019 11:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants