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
n.nep5TokenNative = *nep5
n.validators.Store(keys.PublicKeys(nil))
onp := n.Methods["onPersist"]
onp.Func = getOnPersistWrapper(n.onPersist)
@ -333,7 +334,7 @@ func (n *NEO) ModifyAccountVotes(acc *state.NEOBalanceState, d dao.DAO, value *b
return err
}
}
n.validators.Store(nil)
n.validators.Store(keys.PublicKeys(nil))
return nil
}
@ -386,8 +387,8 @@ func (n *NEO) getRegisteredValidatorsCall(ic *interop.Context, _ []stackitem.Ite
// GetValidatorsInternal returns a list of current validators.
func (n *NEO) GetValidatorsInternal(bc blockchainer.Blockchainer, d dao.DAO) (keys.PublicKeys, error) {
if vals := n.validators.Load(); vals != nil {
return vals.(keys.PublicKeys), nil
if vals := n.validators.Load().(keys.PublicKeys); vals != nil {
return vals, nil
}
standByValidators := bc.GetStandByValidators()
si := d.GetStorageItem(n.ContractID, validatorsCountKey)