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

Gossip V3 #310

Merged
merged 24 commits into from
Dec 11, 2018
Merged

Gossip V3 #310

merged 24 commits into from
Dec 11, 2018

Conversation

y0sher
Copy link
Contributor

@y0sher y0sher commented Dec 6, 2018

This PR handles comments from the first PR #211 about gossip.
Neighborhood which used to be the gossip protocol and in-charge of selecting the peers and connecting them has moved to swarm
gossip.Protocol is now just another protocol used to disseminate messages to peers selected by swarm
this also allowed changing the message structure.

@y0sher y0sher changed the title Gossip V3 [WIP] Gossip V3 Dec 8, 2018
@y0sher y0sher changed the title [WIP] Gossip V3 Gossip V3 Dec 10, 2018

data, err := message.PrepareMessage(session, msg)

func (prot *Protocol) validateMessage(msg *pb.ProtocolMessage, authPubKey crypto.PublicKey) error {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

use message.AuthAuthor


res := d.InternalLookup(dhtid)

if res == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Print an error to the log that we lost the bootstrap nodes

p2p/swarm.go Outdated Show resolved Hide resolved
}

// AuthSender authorizes that a message is signed by its claimed sender
func AuthSender(pm *pb.ProtocolMessage, key crypto.PublicKey) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't really need it, you can verify that the sender in the metadata is the same as the real sender and then use message.AuthAuthor

p2p/swarm.go Outdated Show resolved Hide resolved
p2p/swarm.go Outdated Show resolved Hide resolved
p2p/swarm.go Show resolved Hide resolved
p2p/swarm.go Outdated Show resolved Hide resolved
p2p/swarm.go Outdated Show resolved Hide resolved
p2p/swarm.go Outdated Show resolved Hide resolved
p2p/gossip/protocol.go Outdated Show resolved Hide resolved
p2p/gossip/protocol.go Outdated Show resolved Hide resolved
p2p/gossip/protocol.go Outdated Show resolved Hide resolved
p2p/gossip/protocol.go Outdated Show resolved Hide resolved
s.peersMutex.Lock()
s.peers[cne.n.PublicKey().String()] = p
s.peersMutex.Unlock()
err = prot.validateMessage(msg, authKey)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

use message.AuthAuthor instead

s.oldMessageMu.Lock()
s.oldMessageQ[checksum] = struct{}{}
s.oldMessageMu.Unlock()
sign, err2 := prot.signer.Sign(bin)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

also try using Sign from message

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

Successfully merging this pull request may close these issues.

None yet

2 participants