[#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"
|
name: "NeoFS"
|
||||||
safemethods: ["alphabetList", "innerRingCandidates", "config", "listConfig", "version"]
|
safemethods: ["alphabetList", "alphabetAddress", "innerRingCandidates", "config", "listConfig", "version"]
|
||||||
events:
|
events:
|
||||||
- name: Deposit
|
- name: Deposit
|
||||||
parameters:
|
parameters:
|
||||||
|
|
|
@ -15,6 +15,7 @@ package smart_contract
|
||||||
|
|
||||||
Inner ring list related methods:
|
Inner ring list related methods:
|
||||||
- AlphabetList
|
- AlphabetList
|
||||||
|
- AlphabetAddress
|
||||||
- InnerRingCandidates
|
- InnerRingCandidates
|
||||||
- InnerRingCandidateAdd
|
- InnerRingCandidateAdd
|
||||||
- InnerRingCandidateRemove
|
- InnerRingCandidateRemove
|
||||||
|
@ -26,6 +27,7 @@ package smart_contract
|
||||||
- SetConfig
|
- SetConfig
|
||||||
|
|
||||||
Other utility methods:
|
Other utility methods:
|
||||||
|
- Migrate
|
||||||
- Version
|
- Version
|
||||||
- Cheque
|
- Cheque
|
||||||
*/
|
*/
|
||||||
|
@ -127,6 +129,12 @@ func AlphabetList() []common.IRNode {
|
||||||
return getNodes(ctx, alphabetKey)
|
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.
|
// InnerRingCandidates returns array of inner ring candidate node keys.
|
||||||
func InnerRingCandidates() []common.IRNode {
|
func InnerRingCandidates() []common.IRNode {
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
|
@ -534,3 +542,17 @@ func rmNodeByKey(lst, add []common.IRNode, k []byte) ([]common.IRNode, []common.
|
||||||
|
|
||||||
return newLst, add, flag
|
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