[#79] Panic instead of returning bool value
There is a number of contracts which return only `true` value. Also handling `FAULT` on the client is easier then also checking return value. Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
de255b0a43
commit
db2b1be746
7 changed files with 62 additions and 127 deletions
|
@ -117,7 +117,7 @@ func checkPermission(ir []common.IRNode) bool {
|
|||
return runtime.CheckWitness(node.PublicKey)
|
||||
}
|
||||
|
||||
func Emit() bool {
|
||||
func Emit() {
|
||||
ctx := storage.GetReadOnlyContext()
|
||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
||||
|
||||
|
@ -135,8 +135,7 @@ func Emit() bool {
|
|||
|
||||
proxyGas := gasBalance / 2
|
||||
if proxyGas == 0 {
|
||||
runtime.Log("no gas to emit")
|
||||
return false
|
||||
panic("no gas to emit")
|
||||
}
|
||||
|
||||
gas.Transfer(contractHash, proxyAddr, proxyGas, nil)
|
||||
|
@ -161,8 +160,6 @@ func Emit() bool {
|
|||
|
||||
runtime.Log("utility token has been emitted to inner ring nodes")
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func Vote(epoch int, candidates []interop.PublicKey) {
|
||||
|
|
|
@ -84,7 +84,7 @@ func Migrate(script []byte, manifest []byte) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func Put(rawAuditResult []byte) bool {
|
||||
func Put(rawAuditResult []byte) {
|
||||
ctx := storage.GetContext()
|
||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
||||
|
||||
|
@ -116,8 +116,6 @@ func Put(rawAuditResult []byte) bool {
|
|||
storage.Put(ctx, hdr.ID(), rawAuditResult)
|
||||
|
||||
runtime.Log("audit: result has been saved")
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func Get(id []byte) []byte {
|
||||
|
|
|
@ -126,7 +126,7 @@ func Transfer(from, to interop.Hash160, amount int, data interface{}) bool {
|
|||
return token.transfer(ctx, from, to, amount, false, nil)
|
||||
}
|
||||
|
||||
func TransferX(from, to interop.Hash160, amount int, details []byte) bool {
|
||||
func TransferX(from, to interop.Hash160, amount int, details []byte) {
|
||||
ctx := storage.GetContext()
|
||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
||||
|
||||
|
@ -161,24 +161,21 @@ func TransferX(from, to interop.Hash160, amount int, details []byte) bool {
|
|||
|
||||
n := common.Vote(ctx, id, nodeKey)
|
||||
if n < threshold {
|
||||
return true
|
||||
return
|
||||
}
|
||||
|
||||
common.RemoveVotes(ctx, id)
|
||||
}
|
||||
|
||||
result := token.transfer(ctx, from, to, amount, true, details)
|
||||
if result {
|
||||
runtime.Log("transferX: success")
|
||||
} else {
|
||||
// consider panic there
|
||||
runtime.Log("transferX: fail")
|
||||
if !result {
|
||||
panic("transferX: fail")
|
||||
}
|
||||
|
||||
return result
|
||||
runtime.Log("transferX: success")
|
||||
}
|
||||
|
||||
func Lock(txDetails []byte, from, to interop.Hash160, amount, until int) bool {
|
||||
func Lock(txDetails []byte, from, to interop.Hash160, amount, until int) {
|
||||
ctx := storage.GetContext()
|
||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
||||
|
||||
|
@ -214,7 +211,7 @@ func Lock(txDetails []byte, from, to interop.Hash160, amount, until int) bool {
|
|||
|
||||
n := common.Vote(ctx, id, nodeKey)
|
||||
if n < threshold {
|
||||
return true
|
||||
return
|
||||
}
|
||||
|
||||
common.RemoveVotes(ctx, id)
|
||||
|
@ -230,11 +227,9 @@ func Lock(txDetails []byte, from, to interop.Hash160, amount, until int) bool {
|
|||
|
||||
runtime.Log("lock: created lock account")
|
||||
runtime.Notify("Lock", txDetails, from, to, amount, until)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func NewEpoch(epochNum int) bool {
|
||||
func NewEpoch(epochNum int) {
|
||||
ctx := storage.GetContext()
|
||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
||||
|
||||
|
@ -272,11 +267,9 @@ func NewEpoch(epochNum int) bool {
|
|||
token.transfer(ctx, addr, acc.Parent, acc.Balance, true, details)
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func Mint(to interop.Hash160, amount int, txDetails []byte) bool {
|
||||
func Mint(to interop.Hash160, amount int, txDetails []byte) {
|
||||
ctx := storage.GetContext()
|
||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
||||
|
||||
|
@ -306,7 +299,7 @@ func Mint(to interop.Hash160, amount int, txDetails []byte) bool {
|
|||
|
||||
n := common.Vote(ctx, id, nodeKey)
|
||||
if n < threshold {
|
||||
return true
|
||||
return
|
||||
}
|
||||
|
||||
common.RemoveVotes(ctx, id)
|
||||
|
@ -322,11 +315,9 @@ func Mint(to interop.Hash160, amount int, txDetails []byte) bool {
|
|||
storage.Put(ctx, token.CirculationKey, supply)
|
||||
runtime.Log("mint: assets were minted")
|
||||
runtime.Notify("Mint", to, amount)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func Burn(from interop.Hash160, amount int, txDetails []byte) bool {
|
||||
func Burn(from interop.Hash160, amount int, txDetails []byte) {
|
||||
ctx := storage.GetContext()
|
||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
||||
|
||||
|
@ -356,7 +347,7 @@ func Burn(from interop.Hash160, amount int, txDetails []byte) bool {
|
|||
|
||||
n := common.Vote(ctx, id, nodeKey)
|
||||
if n < threshold {
|
||||
return true
|
||||
return
|
||||
}
|
||||
|
||||
common.RemoveVotes(ctx, id)
|
||||
|
@ -376,8 +367,6 @@ func Burn(from interop.Hash160, amount int, txDetails []byte) bool {
|
|||
storage.Put(ctx, token.CirculationKey, supply)
|
||||
runtime.Log("burn: assets were burned")
|
||||
runtime.Notify("Burn", from, amount)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func Version() int {
|
||||
|
|
|
@ -110,7 +110,7 @@ func Migrate(script []byte, manifest []byte) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func Put(container []byte, signature interop.Signature, publicKey interop.PublicKey, token []byte) bool {
|
||||
func Put(container []byte, signature interop.Signature, publicKey interop.PublicKey, token []byte) {
|
||||
ctx := storage.GetContext()
|
||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
||||
|
||||
|
@ -142,7 +142,7 @@ func Put(container []byte, signature interop.Signature, publicKey interop.Public
|
|||
|
||||
if !alphabetCall {
|
||||
runtime.Notify("containerPut", container, signature, publicKey, token)
|
||||
return true
|
||||
return
|
||||
}
|
||||
|
||||
from := common.WalletToScriptHash(ownerID)
|
||||
|
@ -159,7 +159,7 @@ func Put(container []byte, signature interop.Signature, publicKey interop.Public
|
|||
|
||||
n := common.Vote(ctx, id, nodeKey)
|
||||
if n < threshold {
|
||||
return true
|
||||
return
|
||||
}
|
||||
|
||||
common.RemoveVotes(ctx, id)
|
||||
|
@ -169,16 +169,13 @@ func Put(container []byte, signature interop.Signature, publicKey interop.Public
|
|||
node := alphabet[i]
|
||||
to := contract.CreateStandardAccount(node.PublicKey)
|
||||
|
||||
tx := contract.Call(balanceContractAddr, "transferX",
|
||||
contract.Call(balanceContractAddr, "transferX",
|
||||
contract.All,
|
||||
from,
|
||||
to,
|
||||
containerFee,
|
||||
details,
|
||||
)
|
||||
if !tx.(bool) {
|
||||
panic("put: can't transfer assets for container creation")
|
||||
}
|
||||
}
|
||||
|
||||
addContainer(ctx, containerID, ownerID, cnr)
|
||||
|
@ -188,11 +185,9 @@ func Put(container []byte, signature interop.Signature, publicKey interop.Public
|
|||
}
|
||||
|
||||
runtime.Log("put: added new container")
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func Delete(containerID []byte, signature interop.Signature, token []byte) bool {
|
||||
func Delete(containerID []byte, signature interop.Signature, token []byte) {
|
||||
ctx := storage.GetContext()
|
||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
||||
|
||||
|
@ -218,7 +213,7 @@ func Delete(containerID []byte, signature interop.Signature, token []byte) bool
|
|||
|
||||
if !alphabetCall {
|
||||
runtime.Notify("containerDelete", containerID, signature, token)
|
||||
return true
|
||||
return
|
||||
}
|
||||
|
||||
if notaryDisabled {
|
||||
|
@ -227,7 +222,7 @@ func Delete(containerID []byte, signature interop.Signature, token []byte) bool
|
|||
|
||||
n := common.Vote(ctx, id, nodeKey)
|
||||
if n < threshold {
|
||||
return true
|
||||
return
|
||||
}
|
||||
|
||||
common.RemoveVotes(ctx, id)
|
||||
|
@ -235,8 +230,6 @@ func Delete(containerID []byte, signature interop.Signature, token []byte) bool
|
|||
|
||||
removeContainer(ctx, containerID, ownerID)
|
||||
runtime.Log("delete: remove container")
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func Get(containerID []byte) Container {
|
||||
|
@ -276,7 +269,7 @@ func List(owner []byte) [][]byte {
|
|||
return list
|
||||
}
|
||||
|
||||
func SetEACL(eACL []byte, signature interop.Signature, publicKey interop.PublicKey, token []byte) bool {
|
||||
func SetEACL(eACL []byte, signature interop.Signature, publicKey interop.PublicKey, token []byte) {
|
||||
ctx := storage.GetContext()
|
||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
||||
|
||||
|
@ -307,7 +300,7 @@ func SetEACL(eACL []byte, signature interop.Signature, publicKey interop.PublicK
|
|||
|
||||
if !alphabetCall {
|
||||
runtime.Notify("setEACL", eACL, signature, publicKey, token)
|
||||
return true
|
||||
return
|
||||
}
|
||||
|
||||
rule := ExtendedACL{
|
||||
|
@ -325,7 +318,7 @@ func SetEACL(eACL []byte, signature interop.Signature, publicKey interop.PublicK
|
|||
|
||||
n := common.Vote(ctx, id, nodeKey)
|
||||
if n < threshold {
|
||||
return true
|
||||
return
|
||||
}
|
||||
|
||||
common.RemoveVotes(ctx, id)
|
||||
|
@ -334,8 +327,6 @@ func SetEACL(eACL []byte, signature interop.Signature, publicKey interop.PublicK
|
|||
common.SetSerialized(ctx, key, rule)
|
||||
|
||||
runtime.Log("setEACL: success")
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func EACL(containerID []byte) ExtendedACL {
|
||||
|
@ -349,7 +340,7 @@ func EACL(containerID []byte) ExtendedACL {
|
|||
return getEACL(ctx, containerID)
|
||||
}
|
||||
|
||||
func PutContainerSize(epoch int, cid []byte, usedSize int, pubKey interop.PublicKey) bool {
|
||||
func PutContainerSize(epoch int, cid []byte, usedSize int, pubKey interop.PublicKey) {
|
||||
ctx := storage.GetContext()
|
||||
|
||||
if !runtime.CheckWitness(pubKey) {
|
||||
|
@ -367,7 +358,7 @@ func PutContainerSize(epoch int, cid []byte, usedSize int, pubKey interop.Public
|
|||
for i := range s.estimations {
|
||||
est := s.estimations[i]
|
||||
if common.BytesEqual(est.from, pubKey) {
|
||||
return false
|
||||
panic("invalid estimation")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -379,8 +370,6 @@ func PutContainerSize(epoch int, cid []byte, usedSize int, pubKey interop.Public
|
|||
storage.Put(ctx, key, std.Serialize(s))
|
||||
|
||||
runtime.Log("container: saved container size estimation")
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func GetContainerSize(id []byte) containerSizes {
|
||||
|
@ -434,7 +423,7 @@ func NewEpoch(epochNum int) {
|
|||
}
|
||||
}
|
||||
|
||||
func StartContainerEstimation(epoch int) bool {
|
||||
func StartContainerEstimation(epoch int) {
|
||||
ctx := storage.GetContext()
|
||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
||||
|
||||
|
@ -462,7 +451,7 @@ func StartContainerEstimation(epoch int) bool {
|
|||
|
||||
n := common.Vote(ctx, id, nodeKey)
|
||||
if n < threshold {
|
||||
return true
|
||||
return
|
||||
}
|
||||
|
||||
common.RemoveVotes(ctx, id)
|
||||
|
@ -470,11 +459,9 @@ func StartContainerEstimation(epoch int) bool {
|
|||
|
||||
runtime.Notify("StartEstimation", epoch)
|
||||
runtime.Log("startEstimation: notification has been produced")
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func StopContainerEstimation(epoch int) bool {
|
||||
func StopContainerEstimation(epoch int) {
|
||||
ctx := storage.GetContext()
|
||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
||||
|
||||
|
@ -502,7 +489,7 @@ func StopContainerEstimation(epoch int) bool {
|
|||
|
||||
n := common.Vote(ctx, id, nodeKey)
|
||||
if n < threshold {
|
||||
return true
|
||||
return
|
||||
}
|
||||
|
||||
common.RemoveVotes(ctx, id)
|
||||
|
@ -510,8 +497,6 @@ func StopContainerEstimation(epoch int) bool {
|
|||
|
||||
runtime.Notify("StopEstimation", epoch)
|
||||
runtime.Log("stopEstimation: notification has been produced")
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func Version() int {
|
||||
|
|
|
@ -159,7 +159,7 @@ func InnerRingCandidates() []common.IRNode {
|
|||
}
|
||||
|
||||
// InnerRingCandidateRemove removes key from the list of inner ring candidates.
|
||||
func InnerRingCandidateRemove(key interop.PublicKey) bool {
|
||||
func InnerRingCandidateRemove(key interop.PublicKey) {
|
||||
ctx := storage.GetContext()
|
||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
||||
|
||||
|
@ -204,19 +204,17 @@ func InnerRingCandidateRemove(key interop.PublicKey) bool {
|
|||
|
||||
n := common.Vote(ctx, hashID, nodeKey)
|
||||
if n < threshold {
|
||||
return true
|
||||
return
|
||||
}
|
||||
|
||||
common.RemoveVotes(ctx, hashID)
|
||||
}
|
||||
|
||||
common.SetSerialized(ctx, candidatesKey, nodes)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// InnerRingCandidateAdd adds key to the list of inner ring candidates.
|
||||
func InnerRingCandidateAdd(key interop.PublicKey) bool {
|
||||
func InnerRingCandidateAdd(key interop.PublicKey) {
|
||||
ctx := storage.GetContext()
|
||||
|
||||
if !runtime.CheckWitness(key) {
|
||||
|
@ -242,8 +240,6 @@ func InnerRingCandidateAdd(key interop.PublicKey) bool {
|
|||
|
||||
runtime.Log("irCandidateAdd: candidate has been added")
|
||||
common.SetSerialized(ctx, candidatesKey, list)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// OnNEP17Payment is a callback for NEP-17 compatible native GAS contract.
|
||||
|
@ -279,7 +275,7 @@ func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
|
|||
}
|
||||
|
||||
// Withdraw initialize gas asset withdraw from NeoFS balance.
|
||||
func Withdraw(user interop.Hash160, amount int) bool {
|
||||
func Withdraw(user interop.Hash160, amount int) {
|
||||
if !runtime.CheckWitness(user) {
|
||||
panic("withdraw: you should be the owner of the wallet")
|
||||
}
|
||||
|
@ -322,13 +318,11 @@ func Withdraw(user interop.Hash160, amount int) bool {
|
|||
tx := runtime.GetScriptContainer()
|
||||
|
||||
runtime.Notify("Withdraw", user, amount, tx.Hash)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Cheque sends gas assets back to the user if they were successfully
|
||||
// locked in NeoFS balance contract.
|
||||
func Cheque(id []byte, user interop.Hash160, amount int, lockAcc []byte) bool {
|
||||
func Cheque(id []byte, user interop.Hash160, amount int, lockAcc []byte) {
|
||||
ctx := storage.GetContext()
|
||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
||||
|
||||
|
@ -357,7 +351,7 @@ func Cheque(id []byte, user interop.Hash160, amount int, lockAcc []byte) bool {
|
|||
|
||||
n := common.Vote(ctx, id, nodeKey)
|
||||
if n < threshold {
|
||||
return true
|
||||
return
|
||||
}
|
||||
|
||||
common.RemoveVotes(ctx, id)
|
||||
|
@ -370,12 +364,10 @@ func Cheque(id []byte, user interop.Hash160, amount int, lockAcc []byte) bool {
|
|||
|
||||
runtime.Log("cheque: funds have been transferred")
|
||||
runtime.Notify("Cheque", id, user, amount, lockAcc)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Bind public key with user's account to use it in NeoFS requests.
|
||||
func Bind(user []byte, keys []interop.PublicKey) bool {
|
||||
func Bind(user []byte, keys []interop.PublicKey) {
|
||||
if !runtime.CheckWitness(user) {
|
||||
panic("binding: you should be the owner of the wallet")
|
||||
}
|
||||
|
@ -388,12 +380,10 @@ func Bind(user []byte, keys []interop.PublicKey) bool {
|
|||
}
|
||||
|
||||
runtime.Notify("Bind", user, keys)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Unbind public key from user's account
|
||||
func Unbind(user []byte, keys []interop.PublicKey) bool {
|
||||
func Unbind(user []byte, keys []interop.PublicKey) {
|
||||
if !runtime.CheckWitness(user) {
|
||||
panic("unbinding: you should be the owner of the wallet")
|
||||
}
|
||||
|
@ -406,13 +396,11 @@ func Unbind(user []byte, keys []interop.PublicKey) bool {
|
|||
}
|
||||
|
||||
runtime.Notify("Unbind", user, keys)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// AlphabetUpdate updates list of alphabet nodes with provided list of
|
||||
// public keys.
|
||||
func AlphabetUpdate(id []byte, args []interop.PublicKey) bool {
|
||||
func AlphabetUpdate(id []byte, args []interop.PublicKey) {
|
||||
ctx := storage.GetContext()
|
||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
||||
|
||||
|
@ -456,7 +444,7 @@ func AlphabetUpdate(id []byte, args []interop.PublicKey) bool {
|
|||
|
||||
n := common.Vote(ctx, id, nodeKey)
|
||||
if n < threshold {
|
||||
return true
|
||||
return
|
||||
}
|
||||
|
||||
common.RemoveVotes(ctx, id)
|
||||
|
@ -466,8 +454,6 @@ func AlphabetUpdate(id []byte, args []interop.PublicKey) bool {
|
|||
|
||||
runtime.Notify("AlphabetUpdate", id, newAlphabet)
|
||||
runtime.Log("alphabetUpdate: alphabet list has been updated")
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Config returns value of NeoFS configuration with provided key.
|
||||
|
@ -477,7 +463,7 @@ func Config(key []byte) interface{} {
|
|||
}
|
||||
|
||||
// SetConfig key-value pair as a NeoFS runtime configuration value.
|
||||
func SetConfig(id, key, val []byte) bool {
|
||||
func SetConfig(id, key, val []byte) {
|
||||
ctx := storage.GetContext()
|
||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
||||
|
||||
|
@ -504,7 +490,7 @@ func SetConfig(id, key, val []byte) bool {
|
|||
|
||||
n := common.Vote(ctx, id, nodeKey)
|
||||
if n < threshold {
|
||||
return true
|
||||
return
|
||||
}
|
||||
|
||||
common.RemoveVotes(ctx, id)
|
||||
|
@ -514,8 +500,6 @@ func SetConfig(id, key, val []byte) bool {
|
|||
|
||||
runtime.Notify("SetConfig", id, key, val)
|
||||
runtime.Log("setConfig: configuration has been updated")
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// ListConfig returns array of all key-value pairs of NeoFS configuration.
|
||||
|
@ -538,7 +522,7 @@ func ListConfig() []record {
|
|||
}
|
||||
|
||||
// InitConfig set up initial NeoFS key-value configuration.
|
||||
func InitConfig(args [][]byte) bool {
|
||||
func InitConfig(args [][]byte) {
|
||||
ctx := storage.GetContext()
|
||||
|
||||
if getConfig(ctx, candidateFeeConfigKey) != nil {
|
||||
|
@ -558,8 +542,6 @@ func InitConfig(args [][]byte) bool {
|
|||
}
|
||||
|
||||
runtime.Log("neofs: config has been installed")
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Version of contract.
|
||||
|
|
|
@ -69,7 +69,7 @@ func Migrate(script []byte, manifest []byte) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func AddKey(owner []byte, keys []interop.PublicKey) bool {
|
||||
func AddKey(owner []byte, keys []interop.PublicKey) {
|
||||
if len(owner) != 25 {
|
||||
panic("addKey: incorrect owner")
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ addLoop:
|
|||
|
||||
n := common.Vote(ctx, id, nodeKey)
|
||||
if n < threshold {
|
||||
return true
|
||||
return
|
||||
}
|
||||
|
||||
common.RemoveVotes(ctx, id)
|
||||
|
@ -135,11 +135,9 @@ addLoop:
|
|||
|
||||
common.SetSerialized(ctx, owner, info)
|
||||
runtime.Log("addKey: key bound to the owner")
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func RemoveKey(owner []byte, keys []interop.PublicKey) bool {
|
||||
func RemoveKey(owner []byte, keys []interop.PublicKey) {
|
||||
if len(owner) != 25 {
|
||||
panic("removeKey: incorrect owner")
|
||||
}
|
||||
|
@ -194,15 +192,13 @@ rmLoop:
|
|||
|
||||
n := common.Vote(ctx, id, nodeKey)
|
||||
if n < threshold {
|
||||
return true
|
||||
return
|
||||
}
|
||||
|
||||
common.RemoveVotes(ctx, id)
|
||||
}
|
||||
|
||||
common.SetSerialized(ctx, owner, info)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func Key(owner []byte) [][]byte {
|
||||
|
|
|
@ -127,7 +127,7 @@ func InnerRingList() []common.IRNode {
|
|||
return getIRNodes(ctx)
|
||||
}
|
||||
|
||||
func UpdateInnerRing(keys []interop.PublicKey) bool {
|
||||
func UpdateInnerRing(keys []interop.PublicKey) {
|
||||
ctx := storage.GetContext()
|
||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
||||
|
||||
|
@ -162,7 +162,7 @@ func UpdateInnerRing(keys []interop.PublicKey) bool {
|
|||
|
||||
n := common.Vote(ctx, id, nodeKey)
|
||||
if n < threshold {
|
||||
return true
|
||||
return
|
||||
}
|
||||
|
||||
common.RemoveVotes(ctx, id)
|
||||
|
@ -170,11 +170,9 @@ func UpdateInnerRing(keys []interop.PublicKey) bool {
|
|||
|
||||
runtime.Log("updateInnerRing: inner ring list updated")
|
||||
common.SetSerialized(ctx, innerRingKey, irList)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func AddPeer(nodeInfo []byte) bool {
|
||||
func AddPeer(nodeInfo []byte) {
|
||||
ctx := storage.GetContext()
|
||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
||||
|
||||
|
@ -199,7 +197,7 @@ func AddPeer(nodeInfo []byte) bool {
|
|||
panic("addPeer: witness check failed")
|
||||
}
|
||||
runtime.Notify("AddPeer", nodeInfo)
|
||||
return true
|
||||
return
|
||||
}
|
||||
|
||||
candidate := storageNode{
|
||||
|
@ -215,7 +213,7 @@ func AddPeer(nodeInfo []byte) bool {
|
|||
|
||||
n := common.Vote(ctx, id, nodeKey)
|
||||
if n < threshold {
|
||||
return true
|
||||
return
|
||||
}
|
||||
|
||||
common.RemoveVotes(ctx, id)
|
||||
|
@ -227,11 +225,9 @@ func AddPeer(nodeInfo []byte) bool {
|
|||
common.SetSerialized(ctx, netmapKey, nm)
|
||||
runtime.Log("addPeer: add storage node to the network map")
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func UpdateState(state int, publicKey interop.PublicKey) bool {
|
||||
func UpdateState(state int, publicKey interop.PublicKey) {
|
||||
if len(publicKey) != 33 {
|
||||
panic("updateState: incorrect public key")
|
||||
}
|
||||
|
@ -261,7 +257,7 @@ func UpdateState(state int, publicKey interop.PublicKey) bool {
|
|||
|
||||
runtime.Notify("UpdateState", state, publicKey)
|
||||
|
||||
return true
|
||||
return
|
||||
}
|
||||
|
||||
if notaryDisabled {
|
||||
|
@ -270,7 +266,7 @@ func UpdateState(state int, publicKey interop.PublicKey) bool {
|
|||
|
||||
n := common.Vote(ctx, id, nodeKey)
|
||||
if n < threshold {
|
||||
return true
|
||||
return
|
||||
}
|
||||
|
||||
common.RemoveVotes(ctx, id)
|
||||
|
@ -284,11 +280,9 @@ func UpdateState(state int, publicKey interop.PublicKey) bool {
|
|||
default:
|
||||
panic("updateState: unsupported state")
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func NewEpoch(epochNum int) bool {
|
||||
func NewEpoch(epochNum int) {
|
||||
ctx := storage.GetContext()
|
||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
||||
|
||||
|
@ -316,7 +310,7 @@ func NewEpoch(epochNum int) bool {
|
|||
|
||||
n := common.Vote(ctx, id, nodeKey)
|
||||
if n < threshold {
|
||||
return true
|
||||
return
|
||||
}
|
||||
|
||||
common.RemoveVotes(ctx, id)
|
||||
|
@ -324,7 +318,7 @@ func NewEpoch(epochNum int) bool {
|
|||
|
||||
currentEpoch := storage.Get(ctx, snapshotEpoch).(int)
|
||||
if epochNum <= currentEpoch {
|
||||
return false // ignore invocations with invalid epoch
|
||||
panic("invalid epoch") // ignore invocations with invalid epoch
|
||||
}
|
||||
|
||||
data0snapshot := getSnapshot(ctx, snapshot0Key)
|
||||
|
@ -345,8 +339,6 @@ func NewEpoch(epochNum int) bool {
|
|||
cleanup(ctx, epochNum)
|
||||
|
||||
runtime.Notify("NewEpoch", epochNum)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func Epoch() int {
|
||||
|
@ -387,7 +379,7 @@ func Config(key []byte) interface{} {
|
|||
return getConfig(ctx, key)
|
||||
}
|
||||
|
||||
func SetConfig(id, key, val []byte) bool {
|
||||
func SetConfig(id, key, val []byte) {
|
||||
ctx := storage.GetContext()
|
||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
||||
|
||||
|
@ -414,7 +406,7 @@ func SetConfig(id, key, val []byte) bool {
|
|||
|
||||
n := common.Vote(ctx, id, nodeKey)
|
||||
if n < threshold {
|
||||
return true
|
||||
return
|
||||
}
|
||||
|
||||
common.RemoveVotes(ctx, id)
|
||||
|
@ -423,11 +415,9 @@ func SetConfig(id, key, val []byte) bool {
|
|||
setConfig(ctx, key, val)
|
||||
|
||||
runtime.Log("setConfig: configuration has been updated")
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func InitConfig(args [][]byte) bool {
|
||||
func InitConfig(args [][]byte) {
|
||||
ctx := storage.GetContext()
|
||||
|
||||
if storage.Get(ctx, configuredKey) != nil {
|
||||
|
@ -448,8 +438,6 @@ func InitConfig(args [][]byte) bool {
|
|||
|
||||
storage.Put(ctx, configuredKey, true)
|
||||
runtime.Log("netmap: config has been installed")
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func ListConfig() []record {
|
||||
|
|
Loading…
Reference in a new issue