aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/network/protocol.go
diff options
context:
space:
mode:
authorElad <theman@elad.im>2019-01-17 18:38:23 +0800
committerRafael Matias <rafael@skyle.net>2019-02-19 19:55:18 +0800
commitafb65f6ace9f319c2e4eb4d5d7dc4320c0dcaeea (patch)
treecb971679f528aa46a7480fbb6944082f8996e7ee /swarm/network/protocol.go
parent1f1c751b6e4388f4534f294cd13250f1eb871de5 (diff)
downloadgo-tangerine-afb65f6ace9f319c2e4eb4d5d7dc4320c0dcaeea.tar
go-tangerine-afb65f6ace9f319c2e4eb4d5d7dc4320c0dcaeea.tar.gz
go-tangerine-afb65f6ace9f319c2e4eb4d5d7dc4320c0dcaeea.tar.bz2
go-tangerine-afb65f6ace9f319c2e4eb4d5d7dc4320c0dcaeea.tar.lz
go-tangerine-afb65f6ace9f319c2e4eb4d5d7dc4320c0dcaeea.tar.xz
go-tangerine-afb65f6ace9f319c2e4eb4d5d7dc4320c0dcaeea.tar.zst
go-tangerine-afb65f6ace9f319c2e4eb4d5d7dc4320c0dcaeea.zip
swarm/network: fix data race warning on TestBzzHandshakeLightNode (#18459)
(cherry picked from commit 81e26d5a4837077d5fff17e7b461061b134a4a00)
Diffstat (limited to 'swarm/network/protocol.go')
-rw-r--r--swarm/network/protocol.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/swarm/network/protocol.go b/swarm/network/protocol.go
index a4b29239c..74e7de126 100644
--- a/swarm/network/protocol.go
+++ b/swarm/network/protocol.go
@@ -168,7 +168,7 @@ func (b *Bzz) APIs() []rpc.API {
func (b *Bzz) RunProtocol(spec *protocols.Spec, run func(*BzzPeer) error) func(*p2p.Peer, p2p.MsgReadWriter) error {
return func(p *p2p.Peer, rw p2p.MsgReadWriter) error {
// wait for the bzz protocol to perform the handshake
- handshake, _ := b.GetHandshake(p.ID())
+ handshake, _ := b.GetOrCreateHandshake(p.ID())
defer b.removeHandshake(p.ID())
select {
case <-handshake.done:
@@ -213,7 +213,7 @@ func (b *Bzz) performHandshake(p *protocols.Peer, handshake *HandshakeMsg) error
// runBzz is the p2p protocol run function for the bzz base protocol
// that negotiates the bzz handshake
func (b *Bzz) runBzz(p *p2p.Peer, rw p2p.MsgReadWriter) error {
- handshake, _ := b.GetHandshake(p.ID())
+ handshake, _ := b.GetOrCreateHandshake(p.ID())
if !<-handshake.init {
return fmt.Errorf("%08x: bzz already started on peer %08x", b.localAddr.Over()[:4], p.ID().Bytes()[:4])
}
@@ -303,7 +303,7 @@ func (b *Bzz) removeHandshake(peerID enode.ID) {
}
// GetHandshake returns the bzz handhake that the remote peer with peerID sent
-func (b *Bzz) GetHandshake(peerID enode.ID) (*HandshakeMsg, bool) {
+func (b *Bzz) GetOrCreateHandshake(peerID enode.ID) (*HandshakeMsg, bool) {
b.mtx.Lock()
defer b.mtx.Unlock()
handshake, found := b.handshakes[peerID]