From b17337b8e5ef0d618f2fad355a2855d3b168847f Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Fri, 19 Feb 2021 18:47:02 +0300 Subject: [PATCH] [#51] neofsid: Support notary contract Signed-off-by: Alex Vanin --- neofsid/neofsid_contract.go | 44 ++++--------------------------------- 1 file changed, 4 insertions(+), 40 deletions(-) diff --git a/neofsid/neofsid_contract.go b/neofsid/neofsid_contract.go index aca67c7..2d5a2f6 100644 --- a/neofsid/neofsid_contract.go +++ b/neofsid/neofsid_contract.go @@ -58,20 +58,12 @@ func Migrate(script []byte, manifest []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 { panic("addKey: incorrect owner") } - innerRing := irList() - threshold := len(innerRing)/3*2 + 1 - - irKey := common.InnerRingInvoker(innerRing) - if len(irKey) == 0 { + multiaddr := common.InnerRingMultiAddressViaStorage(ctx, netmapContractKey) + if !runtime.CheckWitness(multiaddr) { panic("addKey: invocation from non inner ring node") } @@ -94,21 +86,6 @@ addLoop: 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) runtime.Log("addKey: key bound to the owner") @@ -120,24 +97,11 @@ func RemoveKey(owner []byte, keys [][]byte) bool { panic("removeKey: incorrect owner") } - innerRing := irList() - threshold := len(innerRing)/3*2 + 1 - - irKey := common.InnerRingInvoker(innerRing) - if len(irKey) == 0 { + multiaddr := common.InnerRingMultiAddressViaStorage(ctx, netmapContractKey) + if !runtime.CheckWitness(multiaddr) { 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) var leftKeys [][]byte