native: don't expose internal slices to the outside world

They should be hidden.
This commit is contained in:
Roman Khimov 2020-07-11 14:07:48 +03:00
parent 7eef895061
commit 579630a3fa

View file

@ -388,13 +388,13 @@ func (n *NEO) getRegisteredValidatorsCall(ic *interop.Context, _ []stackitem.Ite
// GetValidatorsInternal returns a list of current validators. // GetValidatorsInternal returns a list of current validators.
func (n *NEO) GetValidatorsInternal(bc blockchainer.Blockchainer, d dao.DAO) (keys.PublicKeys, error) { func (n *NEO) GetValidatorsInternal(bc blockchainer.Blockchainer, d dao.DAO) (keys.PublicKeys, error) {
if vals := n.validators.Load().(keys.PublicKeys); vals != nil { if vals := n.validators.Load().(keys.PublicKeys); vals != nil {
return vals, nil return vals.Copy(), nil
} }
standByValidators := bc.GetStandByValidators() standByValidators := bc.GetStandByValidators()
si := d.GetStorageItem(n.ContractID, validatorsCountKey) si := d.GetStorageItem(n.ContractID, validatorsCountKey)
if si == nil { if si == nil {
n.validators.Store(standByValidators) n.validators.Store(standByValidators)
return standByValidators, nil return standByValidators.Copy(), nil
} }
validatorsCount, err := ValidatorsCountFromBytes(si.Value) validatorsCount, err := ValidatorsCountFromBytes(si.Value)
if err != nil { if err != nil {