Use RLock instead of Lock

This commit is contained in:
Ingo Oppermann 2023-07-26 11:34:29 +02:00
parent 80feb0b565
commit 8be031a3d1
No known key found for this signature in database
GPG Key ID: 2AB32426E9DD229E

View File

@ -488,13 +488,13 @@ func (n *node) AboutPeer() (clientapi.About, time.Duration, error) {
}
func (n *node) About() NodeAbout {
n.peerLock.Lock()
n.peerLock.RLock()
createdAt, err := time.Parse(time.RFC3339, n.peerAbout.CreatedAt)
if err != nil {
createdAt = time.Now()
}
name := n.peerAbout.Name
n.peerLock.Unlock()
n.peerLock.RUnlock()
n.stateLock.RLock()
defer n.stateLock.RUnlock()
@ -542,8 +542,8 @@ func (n *node) Resources() NodeResources {
}
func (n *node) Version() NodeVersion {
n.peerLock.Lock()
defer n.peerLock.Unlock()
n.peerLock.RLock()
defer n.peerLock.RUnlock()
build, err := time.Parse(time.RFC3339, n.peerAbout.Version.Build)
if err != nil {