forked from TrueCloudLab/neoneo-go
native: fill votes when registering unregistered candidate
If a candidate was registered, then unregistered and then again registered, it's votes must not be lost.
This commit is contained in:
parent
27169d140f
commit
38a92323c9
1 changed files with 6 additions and 3 deletions
|
@ -227,10 +227,13 @@ func (n *NEO) RegisterCandidateInternal(ic *interop.Context, pub *keys.PublicKey
|
|||
key := makeValidatorKey(pub)
|
||||
si := ic.DAO.GetStorageItem(n.ContractID, key)
|
||||
if si == nil {
|
||||
si = new(state.StorageItem)
|
||||
c := &candidate{Registered: true}
|
||||
si = &state.StorageItem{Value: c.Bytes()}
|
||||
} else {
|
||||
c := new(candidate).FromBytes(si.Value)
|
||||
c.Registered = true
|
||||
si.Value = c.Bytes()
|
||||
}
|
||||
c := &candidate{Registered: true}
|
||||
si.Value = c.Bytes()
|
||||
return ic.DAO.PutStorageItem(n.ContractID, key, si)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue