forked from TrueCloudLab/frostfs-contract
[#51] neofsid: Support notary contract
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
f21d09713f
commit
b17337b8e5
1 changed files with 4 additions and 40 deletions
|
@ -58,20 +58,12 @@ func Migrate(script []byte, manifest []byte) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddKey(owner []byte, keys [][]byte) bool {
|
func AddKey(owner []byte, keys [][]byte) bool {
|
||||||
var (
|
|
||||||
n int // number of votes for inner ring invoke
|
|
||||||
id []byte // ballot key of the inner ring invocation
|
|
||||||
)
|
|
||||||
|
|
||||||
if len(owner) != 25 {
|
if len(owner) != 25 {
|
||||||
panic("addKey: incorrect owner")
|
panic("addKey: incorrect owner")
|
||||||
}
|
}
|
||||||
|
|
||||||
innerRing := irList()
|
multiaddr := common.InnerRingMultiAddressViaStorage(ctx, netmapContractKey)
|
||||||
threshold := len(innerRing)/3*2 + 1
|
if !runtime.CheckWitness(multiaddr) {
|
||||||
|
|
||||||
irKey := common.InnerRingInvoker(innerRing)
|
|
||||||
if len(irKey) == 0 {
|
|
||||||
panic("addKey: invocation from non inner ring node")
|
panic("addKey: invocation from non inner ring node")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,21 +86,6 @@ addLoop:
|
||||||
info.Keys = append(info.Keys, pubKey)
|
info.Keys = append(info.Keys, pubKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
fromKnownContract := fromKnownContract(runtime.GetCallingScriptHash())
|
|
||||||
if fromKnownContract {
|
|
||||||
n = threshold
|
|
||||||
runtime.Log("addKey: processed indirect invoke")
|
|
||||||
} else {
|
|
||||||
id := invokeIDKeys(owner, keys, []byte("add"))
|
|
||||||
n = common.Vote(ctx, id, irKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
if n < threshold {
|
|
||||||
runtime.Log("addKey: processed invoke from inner ring")
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
common.RemoveVotes(ctx, id)
|
|
||||||
common.SetSerialized(ctx, owner, info)
|
common.SetSerialized(ctx, owner, info)
|
||||||
runtime.Log("addKey: key bound to the owner")
|
runtime.Log("addKey: key bound to the owner")
|
||||||
|
|
||||||
|
@ -120,24 +97,11 @@ func RemoveKey(owner []byte, keys [][]byte) bool {
|
||||||
panic("removeKey: incorrect owner")
|
panic("removeKey: incorrect owner")
|
||||||
}
|
}
|
||||||
|
|
||||||
innerRing := irList()
|
multiaddr := common.InnerRingMultiAddressViaStorage(ctx, netmapContractKey)
|
||||||
threshold := len(innerRing)/3*2 + 1
|
if !runtime.CheckWitness(multiaddr) {
|
||||||
|
|
||||||
irKey := common.InnerRingInvoker(innerRing)
|
|
||||||
if len(irKey) == 0 {
|
|
||||||
panic("removeKey: invocation from non inner ring node")
|
panic("removeKey: invocation from non inner ring node")
|
||||||
}
|
}
|
||||||
|
|
||||||
id := invokeIDKeys(owner, keys, []byte("remove"))
|
|
||||||
|
|
||||||
n := common.Vote(ctx, id, irKey)
|
|
||||||
if n < threshold {
|
|
||||||
runtime.Log("removeKey: processed invoke from inner ring")
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
common.RemoveVotes(ctx, id)
|
|
||||||
|
|
||||||
info := getUserInfo(ctx, owner)
|
info := getUserInfo(ctx, owner)
|
||||||
var leftKeys [][]byte
|
var leftKeys [][]byte
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue