forked from TrueCloudLab/frostfs-contract
[#58] alphabet: Use alphabet and IR lists from chain
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
4ace86e9b3
commit
5015372135
1 changed files with 6 additions and 9 deletions
|
@ -73,10 +73,6 @@ func Neo() int {
|
||||||
return neo.BalanceOf(runtime.GetExecutingScriptHash())
|
return neo.BalanceOf(runtime.GetExecutingScriptHash())
|
||||||
}
|
}
|
||||||
|
|
||||||
func irList(ctx storage.Context) []common.IRNode {
|
|
||||||
return common.InnerRingListViaStorage(ctx, netmapKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
func currentEpoch(ctx storage.Context) int {
|
func currentEpoch(ctx storage.Context) int {
|
||||||
netmapContractAddr := storage.Get(ctx, netmapKey).(interop.Hash160)
|
netmapContractAddr := storage.Get(ctx, netmapKey).(interop.Hash160)
|
||||||
return contract.Call(netmapContractAddr, "epoch", contract.ReadOnly).(int)
|
return contract.Call(netmapContractAddr, "epoch", contract.ReadOnly).(int)
|
||||||
|
@ -109,8 +105,8 @@ func checkPermission(ir []common.IRNode) bool {
|
||||||
func Emit() bool {
|
func Emit() bool {
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
|
|
||||||
innerRingKeys := irList(ctx)
|
alphabet := common.AlphabetNodes()
|
||||||
if !checkPermission(innerRingKeys) {
|
if !checkPermission(alphabet) {
|
||||||
panic("invalid invoker")
|
panic("invalid invoker")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,10 +126,11 @@ func Emit() bool {
|
||||||
gas.Transfer(contractHash, proxyAddr, proxyGas, nil)
|
gas.Transfer(contractHash, proxyAddr, proxyGas, nil)
|
||||||
runtime.Log("utility token has been emitted to proxy contract")
|
runtime.Log("utility token has been emitted to proxy contract")
|
||||||
|
|
||||||
gasPerNode := gasBalance / 2 * 7 / 8 / len(innerRingKeys)
|
innerRing := common.InnerRingNodes()
|
||||||
|
gasPerNode := gasBalance / 2 * 7 / 8 / len(innerRing)
|
||||||
|
|
||||||
if gasPerNode != 0 {
|
if gasPerNode != 0 {
|
||||||
for _, node := range innerRingKeys {
|
for _, node := range innerRing {
|
||||||
address := contract.CreateStandardAccount(node.PublicKey)
|
address := contract.CreateStandardAccount(node.PublicKey)
|
||||||
gas.Transfer(contractHash, address, gasPerNode, nil)
|
gas.Transfer(contractHash, address, gasPerNode, nil)
|
||||||
}
|
}
|
||||||
|
@ -149,7 +146,7 @@ func Vote(epoch int, candidates []interop.PublicKey) {
|
||||||
index := index(ctx)
|
index := index(ctx)
|
||||||
name := name(ctx)
|
name := name(ctx)
|
||||||
|
|
||||||
multiaddr := common.InnerRingMultiAddressViaStorage(ctx, netmapKey)
|
multiaddr := common.AlphabetAddress()
|
||||||
if !runtime.CheckWitness(multiaddr) {
|
if !runtime.CheckWitness(multiaddr) {
|
||||||
panic("invalid invoker")
|
panic("invalid invoker")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue