results

package
v1.10.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2023 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxQuestions is the maximum number of questions allowed in a VotePackage
	MaxQuestions = 64
)

Variables

This section is empty.

Functions

func NewEmptyVotes

func NewEmptyVotes(voteOpts *models.ProcessVoteOptions) [][]*types.BigInt

NewEmptyVotes creates a new results struct with the given number of questions and options

func ResultsToProto added in v1.8.0

func ResultsToProto(results *Results) *models.ProcessResult

ResultsToProto takes the Results type and builds the protobuf type ProcessResult.

Types

type Results

type Results struct {
	ProcessID    types.HexBytes             `json:"processId"`
	Votes        [][]*types.BigInt          `json:"votes"`
	Weight       *types.BigInt              `json:"weight"`
	EnvelopeType *models.EnvelopeType       `json:"envelopeType"`
	VoteOpts     *models.ProcessVoteOptions `json:"voteOptions"`
	BlockHeight  uint32                     `json:"blockHeight"`
}

Results holds the final results and relevant process info for a vochain process

func ComputeResults added in v1.8.0

func ComputeResults(electionID []byte, st *state.State) (*Results, error)

ComputeResults walks through the envelopes of a process and computes the results.

func ProtoToResults added in v1.8.0

func ProtoToResults(pr *models.ProcessResult) *Results

ProtoToResults takes the protobuf type ProcessResult and builds the Results type.

func (*Results) Add

func (r *Results) Add(new *Results) error

Add adds the total weight and votes from the given Results to the containing Results making the method call.

func (*Results) AddVote

func (r *Results) AddVote(voteValues []int, weight *big.Int, mutex *sync.Mutex) error

AddVote adds the voteValues and weight to the Results struct. Checks are performed according the Ballot Protocol.

func (*Results) Decode added in v1.8.0

func (r *Results) Decode(data []byte) error

Decode deserializes the Results using Gob.

func (*Results) Encode added in v1.8.0

func (r *Results) Encode() ([]byte, error)

Encode serializes the Results using Gob.

func (*Results) String

func (r *Results) String() string

String formats the results in a human-readable string

func (*Results) Sub

func (r *Results) Sub(new *Results) error

Sub subtracts the total weight and votes from the given Results to the containing Results.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL