Skip to content

Commit

Permalink
Merge pull request ethereum#475 from ethersphere/pss-protocol-run
Browse files Browse the repository at this point in the history
swarm/pss: Remove redundant run func param to addpeer
  • Loading branch information
nolash authored Apr 30, 2018
2 parents 14d8ad2 + e4e8223 commit 40485d3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions swarm/pss/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (self *Protocol) Handle(msg []byte, p *p2p.Peer, asymmetric bool, keyid str
} else if (!self.isActiveSymKey(keyid, *self.topic) && !asymmetric) ||
(!self.isActiveAsymKey(keyid, *self.topic) && asymmetric) {

rw, err := self.AddPeer(p, self.proto.Run, *self.topic, asymmetric, keyid)
rw, err := self.AddPeer(p, *self.topic, asymmetric, keyid)
if err != nil {
return err
}
Expand Down Expand Up @@ -197,7 +197,8 @@ func ToP2pMsg(msg []byte) (p2p.Msg, error) {
// `key` and `asymmetric` specifies what encryption key
// to link the peer to.
// The key must exist in the pss store prior to adding the peer.
func (self *Protocol) AddPeer(p *p2p.Peer, run func(*p2p.Peer, p2p.MsgReadWriter) error, topic Topic, asymmetric bool, key string) (p2p.MsgReadWriter, error) {
//func (self *Protocol) AddPeer(p *p2p.Peer, run func(*p2p.Peer, p2p.MsgReadWriter) error, topic Topic, asymmetric bool, key string) (p2p.MsgReadWriter, error) {
func (self *Protocol) AddPeer(p *p2p.Peer, topic Topic, asymmetric bool, key string) (p2p.MsgReadWriter, error) {
rw := &PssReadWriter{
Pss: self.Pss,
rw: make(chan p2p.Msg),
Expand Down Expand Up @@ -226,7 +227,7 @@ func (self *Protocol) AddPeer(p *p2p.Peer, run func(*p2p.Peer, p2p.MsgReadWriter
self.symKeyRWPool[key] = rw
}
go func() {
err := run(p, rw)
err := self.proto.Run(p, rw)
log.Warn(fmt.Sprintf("pss vprotocol quit on %v topic %v: %v", p, topic, err))
}()
return rw, nil
Expand Down
2 changes: 1 addition & 1 deletion swarm/pss/protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func testProtocol(t *testing.T) {
// add right peer's public key as protocol peer on left
nid, _ := discover.HexID("0x00") // this hack is needed to satisfy the p2p method
p := p2p.NewPeer(nid, fmt.Sprintf("%x", common.FromHex(loaddrhex)), []p2p.Cap{})
_, err = pssprotocols[lnodeinfo.ID].protocol.AddPeer(p, pssprotocols[lnodeinfo.ID].run, PingTopic, true, rpubkey)
_, err = pssprotocols[lnodeinfo.ID].protocol.AddPeer(p, PingTopic, true, rpubkey)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 40485d3

Please sign in to comment.