neofs: provide default configuration in _deploy

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2021-07-29 15:02:25 +03:00 committed by Alex Vanin
parent f840afb4cc
commit 781de7fe0d

View file

@ -54,6 +54,7 @@ func _deploy(data interface{}, isUpdate bool) {
owner := args[1].(interop.Hash160) owner := args[1].(interop.Hash160)
addrProc := args[2].(interop.Hash160) addrProc := args[2].(interop.Hash160)
keys := args[3].([]interop.PublicKey) keys := args[3].([]interop.PublicKey)
config := args[4].([][]byte)
ctx := storage.GetContext() ctx := storage.GetContext()
@ -93,6 +94,18 @@ func _deploy(data interface{}, isUpdate bool) {
runtime.Log("neofs contract notary disabled") runtime.Log("neofs contract notary disabled")
} }
ln := len(config)
if ln%2 != 0 {
panic("init: bad configuration")
}
for i := 0; i < ln/2; i++ {
key := config[i*2]
val := config[i*2+1]
setConfig(ctx, key, val)
}
runtime.Log("neofs: contract initialized") runtime.Log("neofs: contract initialized")
} }
@ -529,33 +542,6 @@ func ListConfig() []record {
return config return config
} }
// InitConfig method sets up initial key-value configuration pair. Can be invoked
// only once.
//
// Arguments should contain even number of byte arrays. First byte array is a
// configuration key and the second is configuration value.
func InitConfig(args [][]byte) {
ctx := storage.GetContext()
if getConfig(ctx, candidateFeeConfigKey) != nil {
panic("neofs: configuration already installed")
}
ln := len(args)
if ln%2 != 0 {
panic("initConfig: bad arguments")
}
for i := 0; i < ln/2; i++ {
key := args[i*2]
val := args[i*2+1]
setConfig(ctx, key, val)
}
runtime.Log("neofs: config has been installed")
}
// Version returns version of the contract. // Version returns version of the contract.
func Version() int { func Version() int {
return common.Version return common.Version