mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
swarm/network: add lock to seen map in discovery
This commit is contained in:
parent
31d9c08d3b
commit
53be4c9e99
1 changed files with 4 additions and 0 deletions
|
|
@ -2,6 +2,7 @@ package network
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
)
|
)
|
||||||
|
|
@ -11,6 +12,7 @@ import (
|
||||||
type discPeer struct {
|
type discPeer struct {
|
||||||
*bzzPeer
|
*bzzPeer
|
||||||
overlay Overlay
|
overlay Overlay
|
||||||
|
mtx sync.Mutex
|
||||||
peers map[string]bool
|
peers map[string]bool
|
||||||
depth uint8 // the proximity radius advertised by remote to subscribe to peers
|
depth uint8 // the proximity radius advertised by remote to subscribe to peers
|
||||||
sentPeers bool // set to true when the peer is first notifed of peers close to them
|
sentPeers bool // set to true when the peer is first notifed of peers close to them
|
||||||
|
|
@ -206,6 +208,8 @@ func RequestOrder(k Overlay, order, broadcastSize, maxPeers uint8) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *discPeer) seen(p OverlayPeer) bool {
|
func (self *discPeer) seen(p OverlayPeer) bool {
|
||||||
|
self.mtx.Lock()
|
||||||
|
defer self.mtx.Unlock()
|
||||||
k := string(p.Address())
|
k := string(p.Address())
|
||||||
if self.peers[k] {
|
if self.peers[k] {
|
||||||
return true
|
return true
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue