frostfs-node/pkg/innerring/invoke/alphabet.go
Alex Vanin e2547f5bf8 [#170] Invoke all alphabet contracts for voting
Now alphabet contracts use signature collection to make
a vote. All inner ring nodes votes for some list of validators
the same way as they vote fore new epoch or new container.
As soon as list is accepted by alphabet contracts, each of them
votes for one candidate from the list.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-12-10 17:22:37 +03:00

36 lines
905 B
Go

package invoke
import (
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
)
const (
emitMethod = "emit"
voteMethod = "vote"
)
// AlphabetEmit invokes emit method on alphabet contract.
func AlphabetEmit(cli *client.Client, con util.Uint160) error {
if cli == nil {
return client.ErrNilClient
}
// there is no signature collecting, so we don't need extra fee
return cli.Invoke(con, 0, emitMethod)
}
// AlphabetVote invokes vote method on alphabet contract.
func AlphabetVote(cli *client.Client, con util.Uint160, epoch uint64, keys []keys.PublicKey) 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.Invoke(con, feeOneGas, voteMethod, int64(epoch), binaryKeys)
}