forked from TrueCloudLab/frostfs-contract
Add "IsInnerRing" method
Inner ring nodes check their presence in inner ring list during startup. "IsInnerRing" method allows to check presence efficiently by calling this method.
This commit is contained in:
parent
d97a4a9955
commit
9f33939dee
1 changed files with 39 additions and 19 deletions
|
@ -44,6 +44,7 @@ func Main(op string, args []interface{}) interface{} {
|
||||||
- Deposit(params: pubKey, amount) - deposit GAS to the NeoFS account
|
- Deposit(params: pubKey, amount) - deposit GAS to the NeoFS account
|
||||||
- Withdraw(params: withdrawCheque) - withdraw GAS from the NeoFS account
|
- Withdraw(params: withdrawCheque) - withdraw GAS from the NeoFS account
|
||||||
- InnerRingUpdate(params: irCheque) - change list of inner ring nodes
|
- InnerRingUpdate(params: irCheque) - change list of inner ring nodes
|
||||||
|
- IsInnerRing(params: pubKey) - returns true if pubKey presented in inner ring list
|
||||||
- Version() - get version of the NeoFS smart-contract
|
- Version() - get version of the NeoFS smart-contract
|
||||||
|
|
||||||
Params:
|
Params:
|
||||||
|
@ -53,7 +54,6 @@ func Main(op string, args []interface{}) interface{} {
|
||||||
contains inner ring signatures
|
contains inner ring signatures
|
||||||
- irCheque - serialized structure, that confirms new inner ring node list;
|
- irCheque - serialized structure, that confirms new inner ring node list;
|
||||||
contains inner ring signatures
|
contains inner ring signatures
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
@ -265,6 +265,26 @@ func Main(op string, args []interface{}) interface{} {
|
||||||
putSerialized(ctx, "UsedVerifCheckList", c)
|
putSerialized(ctx, "UsedVerifCheckList", c)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
case "IsInnerRing":
|
||||||
|
if len(args) != 1 {
|
||||||
|
panic("isInnerRing: wrong arguments")
|
||||||
|
}
|
||||||
|
|
||||||
|
key := args[0].([]byte)
|
||||||
|
if len(key) != 33 {
|
||||||
|
panic("isInnerRing: incorrect public key")
|
||||||
|
}
|
||||||
|
|
||||||
|
irList := getSerialized(ctx, "InnerRingList").([]node)
|
||||||
|
for i := range irList {
|
||||||
|
node := irList[i]
|
||||||
|
|
||||||
|
if util.Equals(node.pub, key) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
case "Version":
|
case "Version":
|
||||||
return version
|
return version
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue