[#74] neofs: Add AlphabetAddress
method
This method returns multi signature address of alphabet nodes in NeoFS contract. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
ef0d6f02fd
commit
be6c280032
2 changed files with 23 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
name: "NeoFS"
|
||||
safemethods: ["alphabetList", "innerRingCandidates", "config", "listConfig", "version"]
|
||||
safemethods: ["alphabetList", "alphabetAddress", "innerRingCandidates", "config", "listConfig", "version"]
|
||||
events:
|
||||
- name: Deposit
|
||||
parameters:
|
||||
|
|
|
@ -15,6 +15,7 @@ package smart_contract
|
|||
|
||||
Inner ring list related methods:
|
||||
- AlphabetList
|
||||
- AlphabetAddress
|
||||
- InnerRingCandidates
|
||||
- InnerRingCandidateAdd
|
||||
- InnerRingCandidateRemove
|
||||
|
@ -26,6 +27,7 @@ package smart_contract
|
|||
- SetConfig
|
||||
|
||||
Other utility methods:
|
||||
- Migrate
|
||||
- Version
|
||||
- Cheque
|
||||
*/
|
||||
|
@ -127,6 +129,12 @@ func AlphabetList() []common.IRNode {
|
|||
return getNodes(ctx, alphabetKey)
|
||||
}
|
||||
|
||||
// AlphabetAddress returns 2\3n+1 multi signature address of alphabet nodes.
|
||||
func AlphabetAddress() interop.Hash160 {
|
||||
ctx := storage.GetReadOnlyContext()
|
||||
return multiaddress(getNodes(ctx, alphabetKey))
|
||||
}
|
||||
|
||||
// InnerRingCandidates returns array of inner ring candidate node keys.
|
||||
func InnerRingCandidates() []common.IRNode {
|
||||
ctx := storage.GetReadOnlyContext()
|
||||
|
@ -534,3 +542,17 @@ func rmNodeByKey(lst, add []common.IRNode, k []byte) ([]common.IRNode, []common.
|
|||
|
||||
return newLst, add, flag
|
||||
}
|
||||
|
||||
// multiaddress returns multi signature address from list of IRNode structures
|
||||
// with m = 2/3n+1.
|
||||
func multiaddress(n []common.IRNode) []byte {
|
||||
threshold := len(n)*2/3 + 1
|
||||
|
||||
keys := []interop.PublicKey{}
|
||||
for _, node := range n {
|
||||
key := node.PublicKey
|
||||
keys = append(keys, key)
|
||||
}
|
||||
|
||||
return contract.CreateMultisigAccount(threshold, keys)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue