forked from TrueCloudLab/frostfs-contract
[#58] neofs: Allow alphabet nodes to remove candidates
When alphabet nodes update inner ring list with new candidate, then they remove it from neofs contract. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
e74d8bf48d
commit
80eadb4e5e
1 changed files with 15 additions and 1 deletions
|
@ -143,7 +143,21 @@ func InnerRingCandidateRemove(key interop.PublicKey) bool {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if !runtime.CheckWitness(key) {
|
if !runtime.CheckWitness(key) {
|
||||||
panic("irCandidateRemove: you should be the owner of the public key")
|
alphabet := getNodes(ctx, alphabetKey)
|
||||||
|
threshold := len(alphabet)/3*2 + 1
|
||||||
|
|
||||||
|
nodeKey := common.InnerRingInvoker(alphabet)
|
||||||
|
if len(nodeKey) == 0 {
|
||||||
|
panic("irCandidateRemove: invoked by non alphabet node")
|
||||||
|
}
|
||||||
|
|
||||||
|
id := append(key, []byte("delete")...)
|
||||||
|
hashID := crypto.Sha256(id)
|
||||||
|
|
||||||
|
n := common.Vote(ctx, hashID, nodeKey)
|
||||||
|
if n < threshold {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nodes := []common.IRNode{} // it is explicit declaration of empty slice, not nil
|
nodes := []common.IRNode{} // it is explicit declaration of empty slice, not nil
|
||||||
|
|
Loading…
Reference in a new issue