diff options
author | gluk256 <gluk256@gmail.com> | 2019-02-17 13:29:41 +0800 |
---|---|---|
committer | Rafael Matias <rafael@skyle.net> | 2019-02-19 20:11:52 +0800 |
commit | d6c1fcbe045c94cf629a9df956bd7aef7dcf8d72 (patch) | |
tree | d244f30c302b3185e966d0355af4602da5d9e851 /swarm/pss/protocol.go | |
parent | 79cac793c013832457a89911cc477f345e46ced9 (diff) | |
download | go-tangerine-d6c1fcbe045c94cf629a9df956bd7aef7dcf8d72.tar go-tangerine-d6c1fcbe045c94cf629a9df956bd7aef7dcf8d72.tar.gz go-tangerine-d6c1fcbe045c94cf629a9df956bd7aef7dcf8d72.tar.bz2 go-tangerine-d6c1fcbe045c94cf629a9df956bd7aef7dcf8d72.tar.lz go-tangerine-d6c1fcbe045c94cf629a9df956bd7aef7dcf8d72.tar.xz go-tangerine-d6c1fcbe045c94cf629a9df956bd7aef7dcf8d72.tar.zst go-tangerine-d6c1fcbe045c94cf629a9df956bd7aef7dcf8d72.zip |
swarm/pss: refactoring (#19110)
* swarm/pss: split pss and keystore
* swarm/pss: moved whisper to keystore
* swarm/pss: goimports fixed
(cherry picked from commit 12ca3b172a7e1b2b63ef2369e8dc37c75144c81f)
Diffstat (limited to 'swarm/pss/protocol.go')
-rw-r--r-- | swarm/pss/protocol.go | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/swarm/pss/protocol.go b/swarm/pss/protocol.go index 5f47ee47d..7f186f615 100644 --- a/swarm/pss/protocol.go +++ b/swarm/pss/protocol.go @@ -228,7 +228,6 @@ func ToP2pMsg(msg []byte) (p2p.Msg, error) { // to link the peer to. // The key must exist in the pss store prior to adding the peer. func (p *Protocol) AddPeer(peer *p2p.Peer, topic Topic, asymmetric bool, key string) (p2p.MsgReadWriter, error) { - var ok bool rw := &PssReadWriter{ Pss: p.Pss, rw: make(chan p2p.Msg), @@ -242,20 +241,14 @@ func (p *Protocol) AddPeer(peer *p2p.Peer, topic Topic, asymmetric bool, key str rw.sendFunc = p.Pss.SendSym } if asymmetric { - p.Pss.pubKeyPoolMu.Lock() - _, ok = p.Pss.pubKeyPool[key] - p.Pss.pubKeyPoolMu.Unlock() - if !ok { + if !p.Pss.isPubKeyStored(key) { return nil, fmt.Errorf("asym key does not exist: %s", key) } p.RWPoolMu.Lock() p.pubKeyRWPool[key] = rw p.RWPoolMu.Unlock() } else { - p.Pss.symKeyPoolMu.Lock() - _, ok = p.Pss.symKeyPool[key] - p.Pss.symKeyPoolMu.Unlock() - if !ok { + if !p.Pss.isSymKeyStored(key) { return nil, fmt.Errorf("symkey does not exist: %s", key) } p.RWPoolMu.Lock() |