mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
p2p/simulations: use RLock where possible
This commit is contained in:
parent
bba796bc62
commit
fc086dcd80
1 changed files with 8 additions and 8 deletions
|
|
@ -373,16 +373,16 @@ func (net *Network) DidReceive(sender, receiver enode.ID, proto string, code uin
|
|||
// GetNode gets the node with the given ID, returning nil if the node does not
|
||||
// exist
|
||||
func (net *Network) GetNode(id enode.ID) *Node {
|
||||
net.lock.Lock()
|
||||
defer net.lock.Unlock()
|
||||
net.lock.RLock()
|
||||
defer net.lock.RUnlock()
|
||||
return net.getNode(id)
|
||||
}
|
||||
|
||||
// GetNode gets the node with the given name, returning nil if the node does
|
||||
// not exist
|
||||
func (net *Network) GetNodeByName(name string) *Node {
|
||||
net.lock.Lock()
|
||||
defer net.lock.Unlock()
|
||||
net.lock.RLock()
|
||||
defer net.lock.RUnlock()
|
||||
return net.getNodeByName(name)
|
||||
}
|
||||
|
||||
|
|
@ -397,8 +397,8 @@ func (net *Network) getNodeByName(name string) *Node {
|
|||
|
||||
// GetNodes returns the existing nodes
|
||||
func (net *Network) GetNodes() (nodes []*Node) {
|
||||
net.lock.Lock()
|
||||
defer net.lock.Unlock()
|
||||
net.lock.RLock()
|
||||
defer net.lock.RUnlock()
|
||||
|
||||
nodes = append(nodes, net.Nodes...)
|
||||
return nodes
|
||||
|
|
@ -471,8 +471,8 @@ func filterIDs(ids []enode.ID, excludeIDs []enode.ID) []enode.ID {
|
|||
// GetConn returns the connection which exists between "one" and "other"
|
||||
// regardless of which node initiated the connection
|
||||
func (net *Network) GetConn(oneID, otherID enode.ID) *Conn {
|
||||
net.lock.Lock()
|
||||
defer net.lock.Unlock()
|
||||
net.lock.RLock()
|
||||
defer net.lock.RUnlock()
|
||||
return net.getConn(oneID, otherID)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue