forked from TrueCloudLab/frostfs-node
[#447] innerring: Use alias type for slice of public keys
Alias type provide sort function so it is better to use it everywhere where list of public keys is presented. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
34f25adc8c
commit
3965cc2296
4 changed files with 10 additions and 15 deletions
|
@ -100,7 +100,7 @@ func main() {
|
|||
log.Info("application stopped")
|
||||
}
|
||||
|
||||
func parsePublicKeysFromString(argument string) ([]keys.PublicKey, error) {
|
||||
func parsePublicKeysFromString(argument string) (keys.PublicKeys, error) {
|
||||
publicKeysString := strings.Split(argument, ",")
|
||||
|
||||
return innerring.ParsePublicKeysFromStrings(publicKeysString)
|
||||
|
|
|
@ -62,7 +62,7 @@ type (
|
|||
key *ecdsa.PrivateKey
|
||||
pubKey []byte
|
||||
contracts *contracts
|
||||
predefinedValidators []keys.PublicKey
|
||||
predefinedValidators keys.PublicKeys
|
||||
|
||||
workers []func(context.Context)
|
||||
|
||||
|
@ -664,7 +664,7 @@ func parseContracts(cfg *viper.Viper) (*contracts, error) {
|
|||
return result, nil
|
||||
}
|
||||
|
||||
func parsePredefinedValidators(cfg *viper.Viper) ([]keys.PublicKey, error) {
|
||||
func parsePredefinedValidators(cfg *viper.Viper) (keys.PublicKeys, error) {
|
||||
publicKeyStrings := cfg.GetStringSlice("morph.validators")
|
||||
|
||||
return ParsePublicKeysFromStrings(publicKeyStrings)
|
||||
|
@ -672,8 +672,8 @@ func parsePredefinedValidators(cfg *viper.Viper) ([]keys.PublicKey, error) {
|
|||
|
||||
// ParsePublicKeysFromStrings returns slice of neo public keys from slice
|
||||
// of hex encoded strings.
|
||||
func ParsePublicKeysFromStrings(pubKeys []string) ([]keys.PublicKey, error) {
|
||||
publicKeys := make([]keys.PublicKey, 0, len(pubKeys))
|
||||
func ParsePublicKeysFromStrings(pubKeys []string) (keys.PublicKeys, error) {
|
||||
publicKeys := make(keys.PublicKeys, 0, len(pubKeys))
|
||||
|
||||
for i := range pubKeys {
|
||||
key, err := keys.NewPublicKeyFromString(pubKeys[i])
|
||||
|
@ -681,7 +681,7 @@ func ParsePublicKeysFromStrings(pubKeys []string) ([]keys.PublicKey, error) {
|
|||
return nil, errors.Wrap(err, "can't decode public key")
|
||||
}
|
||||
|
||||
publicKeys = append(publicKeys, *key)
|
||||
publicKeys = append(publicKeys, key)
|
||||
}
|
||||
|
||||
return publicKeys, nil
|
||||
|
|
|
@ -22,15 +22,10 @@ func AlphabetEmit(cli *client.Client, con util.Uint160) error {
|
|||
}
|
||||
|
||||
// AlphabetVote invokes vote method on alphabet contract.
|
||||
func AlphabetVote(cli *client.Client, con util.Uint160, epoch uint64, keys []keys.PublicKey) error {
|
||||
func AlphabetVote(cli *client.Client, con util.Uint160, epoch uint64, keys keys.PublicKeys) error {
|
||||
if cli == nil {
|
||||
return client.ErrNilClient
|
||||
}
|
||||
|
||||
binaryKeys := make([][]byte, 0, len(keys))
|
||||
for i := range keys {
|
||||
binaryKeys = append(binaryKeys, keys[i].Bytes())
|
||||
}
|
||||
|
||||
return cli.NotaryInvoke(con, voteMethod, int64(epoch), binaryKeys)
|
||||
return cli.NotaryInvoke(con, voteMethod, int64(epoch), keys)
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ func (s *Server) AlphabetIndex() int {
|
|||
return int(index)
|
||||
}
|
||||
|
||||
func (s *Server) voteForSidechainValidator(validators []keys.PublicKey) error {
|
||||
func (s *Server) voteForSidechainValidator(validators keys.PublicKeys) error {
|
||||
index := s.InnerRingIndex()
|
||||
if s.contracts.alphabet.indexOutOfRange(index) {
|
||||
s.log.Info("ignore validator vote: node not in alphabet range")
|
||||
|
@ -96,7 +96,7 @@ func (s *Server) voteForSidechainValidator(validators []keys.PublicKey) error {
|
|||
// InitAndVoteForSidechainValidator is a public function to use outside of
|
||||
// inner ring daemon execution. It initialize inner ring structure with data
|
||||
// from blockchain and then calls vote method on corresponding alphabet contract.
|
||||
func (s *Server) InitAndVoteForSidechainValidator(validators []keys.PublicKey) error {
|
||||
func (s *Server) InitAndVoteForSidechainValidator(validators keys.PublicKeys) error {
|
||||
err := s.initConfigFromBlockchain()
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in a new issue