native: store typed nil in validators cache

Fix `error encountered at instruction 0 (SYSCALL): sync/atomic: store of nil value into Value"`.
This commit is contained in:
Evgenii Stratonikov 2020-06-29 10:36:44 +03:00
parent f67b8ce607
commit bbe02ac584

View file

@ -77,6 +77,7 @@ func NewNEO() *NEO {
nep5.ContractID = neoContractID nep5.ContractID = neoContractID
n.nep5TokenNative = *nep5 n.nep5TokenNative = *nep5
n.validators.Store(keys.PublicKeys(nil))
onp := n.Methods["onPersist"] onp := n.Methods["onPersist"]
onp.Func = getOnPersistWrapper(n.onPersist) onp.Func = getOnPersistWrapper(n.onPersist)
@ -333,7 +334,7 @@ func (n *NEO) ModifyAccountVotes(acc *state.NEOBalanceState, d dao.DAO, value *b
return err return err
} }
} }
n.validators.Store(nil) n.validators.Store(keys.PublicKeys(nil))
return nil return nil
} }
@ -386,8 +387,8 @@ 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(); vals != nil { if vals := n.validators.Load().(keys.PublicKeys); vals != nil {
return vals.(keys.PublicKeys), nil return vals, nil
} }
standByValidators := bc.GetStandByValidators() standByValidators := bc.GetStandByValidators()
si := d.GetStorageItem(n.ContractID, validatorsCountKey) si := d.GetStorageItem(n.ContractID, validatorsCountKey)