forked from TrueCloudLab/frostfs-node
[#86] Add alphabet contract configuration
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
dcb384d551
commit
6bc787bb19
2 changed files with 33 additions and 0 deletions
|
@ -64,6 +64,14 @@ func defaultConfiguration(cfg *viper.Viper) {
|
||||||
cfg.SetDefault("contracts.neofs", "")
|
cfg.SetDefault("contracts.neofs", "")
|
||||||
cfg.SetDefault("contracts.balance", "")
|
cfg.SetDefault("contracts.balance", "")
|
||||||
cfg.SetDefault("contracts.container", "")
|
cfg.SetDefault("contracts.container", "")
|
||||||
|
// alphabet contracts
|
||||||
|
cfg.SetDefault("contracts.alphabet.az", "")
|
||||||
|
cfg.SetDefault("contracts.alphabet.buky", "")
|
||||||
|
cfg.SetDefault("contracts.alphabet.vedi", "")
|
||||||
|
cfg.SetDefault("contracts.alphabet.glagoli", "")
|
||||||
|
cfg.SetDefault("contracts.alphabet.dobro", "")
|
||||||
|
cfg.SetDefault("contracts.alphabet.jest", "")
|
||||||
|
cfg.SetDefault("contracts.alphabet.zhivete", "")
|
||||||
// gas native contract in LE
|
// gas native contract in LE
|
||||||
cfg.SetDefault("contracts.gas", "668e0c1f9d7b70a99dd9e06eadd4c784d641afbc")
|
cfg.SetDefault("contracts.gas", "668e0c1f9d7b70a99dd9e06eadd4c784d641afbc")
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,8 @@ type (
|
||||||
reputation util.Uint160 // in morph
|
reputation util.Uint160 // in morph
|
||||||
neofsid util.Uint160 // in morph
|
neofsid util.Uint160 // in morph
|
||||||
gas util.Uint160 // native contract in both chains
|
gas util.Uint160 // native contract in both chains
|
||||||
|
|
||||||
|
alphabet [alphabetContractsN]util.Uint160 // in morph
|
||||||
}
|
}
|
||||||
|
|
||||||
chainParams struct {
|
chainParams struct {
|
||||||
|
@ -65,6 +67,8 @@ type (
|
||||||
const (
|
const (
|
||||||
morphPrefix = "morph"
|
morphPrefix = "morph"
|
||||||
mainnetPrefix = "mainnet"
|
mainnetPrefix = "mainnet"
|
||||||
|
|
||||||
|
alphabetContractsN = 7 // az, buky, vedi, glagoli, dobro, jest, zhivete
|
||||||
)
|
)
|
||||||
|
|
||||||
// Start runs all event providers.
|
// Start runs all event providers.
|
||||||
|
@ -297,9 +301,30 @@ func parseContracts(cfg *viper.Viper) (*contracts, error) {
|
||||||
return nil, errors.Wrap(err, "ir: can't read container script-hash")
|
return nil, errors.Wrap(err, "ir: can't read container script-hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result.alphabet, err = parseAlphabetContracts(cfg)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func parseAlphabetContracts(cfg *viper.Viper) (res [7]util.Uint160, err error) {
|
||||||
|
// list of glagolic script letters that represent alphabet contracts
|
||||||
|
glagolic := []string{"az", "buky", "vedi", "glagoli", "dobro", "jest", "zhivete"}
|
||||||
|
|
||||||
|
for i, letter := range glagolic {
|
||||||
|
contractStr := cfg.GetString("contracts.alphabet." + letter)
|
||||||
|
|
||||||
|
res[i], err = util.Uint160DecodeStringLE(contractStr)
|
||||||
|
if err != nil {
|
||||||
|
return res, errors.Wrapf(err, "ir: can't read alphabet %s contract", letter)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
func initConfigFromBlockchain(s *Server, c *contracts, key *ecdsa.PublicKey) error {
|
func initConfigFromBlockchain(s *Server, c *contracts, key *ecdsa.PublicKey) error {
|
||||||
// get current epoch
|
// get current epoch
|
||||||
epoch, err := invoke.Epoch(s.morphClient, c.netmap)
|
epoch, err := invoke.Epoch(s.morphClient, c.netmap)
|
||||||
|
|
Loading…
Reference in a new issue