From a6a0c1eb12e5f2b289fdfb73fe2c4cfc5d8288cc Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Wed, 20 Apr 2022 18:42:49 +0300 Subject: [PATCH] core: avoid lock copy in private DAO constructor Fix the following linter warning: ``` pkg/core/dao/dao.go:101:7 govet copylocks: assignment copies lock value to *d: github.com/nspcc-dev/neo-go/pkg/core/dao.Simple contains sync.RWMutex ``` --- pkg/core/dao/dao.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/core/dao/dao.go b/pkg/core/dao/dao.go index db9bc0807..af268e679 100644 --- a/pkg/core/dao/dao.go +++ b/pkg/core/dao/dao.go @@ -92,8 +92,11 @@ func (dao *Simple) GetWrapped() *Simple { // GetPrivate returns new DAO instance with another layer of private // MemCachedStore around the current DAO Store. func (dao *Simple) GetPrivate() *Simple { - d := &Simple{} - *d = *dao // Inherit everything... + d := &Simple{ + Version: dao.Version, + keyBuf: dao.keyBuf, + dataBuf: dao.dataBuf, + } // Inherit everything... d.Store = storage.NewPrivateMemCachedStore(dao.Store) // except storage, wrap another layer. d.private = true d.nativeCachePS = dao