chaincode

package
v0.0.0-...-f6ab105 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Key

func Key(entity HasBioDataInterface) string

Key returns voter.Biodata.NationalID if voter.Biodata.DID is empty.

Types

type BioData

type BioData struct {
	//DID Digital Identifier
	DID         string
	NationalID  string
	FirstName   string
	MiddleName  string
	LastName    string
	OtherName   string
	Sex         string
	BirthDay    int
	BirtMonth   int
	BirthYear   int
	Gender      string
	Citizenship string
}

BioData is the data of any person that can or cannot vote. Biodata is expected to be extended as demand requires.

func (*BioData) Age

func (b *BioData) Age() int

Age returns calculated age of person

func (*BioData) EligibilityToVote

func (b *BioData) EligibilityToVote() bool

type Candidate

type Candidate struct {
	BioData                 BioData
	CandidateID             string
	CandidatePoliticalParty PoliticalParty
	Votes                   uint64
}

Candidate struct. Candidate is expected to be extended as demand requires.

func (Candidate) HasBioData

func (c Candidate) HasBioData() BioData

type Election

type Election struct {
	ElectionYear int
	Position     string
	Contestants  []Candidate
	Winner       map[Role]Candidate
}

Election struct. Election is expected to be extended as demand requires.

type HasBioDataInterface

type HasBioDataInterface interface {
	//HasBioData returns BioData type
	HasBioData() BioData
}

HasBioDataInterface constraint for type that as Biodata type

type ITYPES

type ITYPES interface {
	Voter | Candidate | Election | PoliticalParty
}

ITYPES is a union set type constraint that enforces only allowable types are passed to smartcontract methods.

type PoliticalParty

type PoliticalParty struct {
	PartyName        string
	PartyID          string
	PartyAbbrevation string
}

PoliticalParty struct. PoliticalParty is expected to be extended as demand requires.

type Role

type Role string

Role is the contested position.

type SmartContract

type SmartContract struct {
	contractapi.Contract
}

func (*SmartContract) DeleteCandidate

func (s *SmartContract) DeleteCandidate(ctx contractapi.TransactionContextInterface, key string) error

DeleteCandidate deletes candidate from world state.

func (*SmartContract) DeleteElection

DeleteElection deletes election from world state.

func (*SmartContract) DeletePoliticalParty

func (s *SmartContract) DeletePoliticalParty(ctx contractapi.TransactionContextInterface, key string) error

DeletePoliticalParty deletes politicalparty from world state.

func (*SmartContract) DeleteVoter

DeleteVoter deletes voter from world state.

func (*SmartContract) QueryAllCandidate

func (s *SmartContract) QueryAllCandidate(ctx contractapi.TransactionContextInterface) ([]Candidate, error)

QueryAllCandidate queryAlls candidate from world state.Any error encounter would return the function with a nil slice.

func (*SmartContract) QueryAllElection

func (s *SmartContract) QueryAllElection(ctx contractapi.TransactionContextInterface) ([]Election, error)

QueryAllElection queryAlls election from world state. Any error encounter would return the function with a nil slice.

func (*SmartContract) QueryAllPoliticalParty

func (s *SmartContract) QueryAllPoliticalParty(ctx contractapi.TransactionContextInterface) ([]PoliticalParty, error)

QueryAllPoliticalParty queryAlls politicalparty from world state. Any error encounter would return the function with a nil slice.

func (*SmartContract) QueryAllVoter

QueryAllVoter queryAlls voter from world state.Any error encounter would return the function with a nil slice.

func (*SmartContract) QueryCandidate

QueryCandidate querys candidate from world state.

func (*SmartContract) QueryElection

QueryElection querys election from world state.

func (*SmartContract) QueryPoliticalParty

QueryPoliticalParty querys politicalparty from world state.

func (*SmartContract) QueryVoter

QueryVoter querys voter from world state.

func (*SmartContract) RegisterCandidate

func (s *SmartContract) RegisterCandidate(ctx contractapi.TransactionContextInterface, candidate Candidate) error

RegisterCandidate registers candidate to world state. candidate is expected to be prepared by the backend.

func (*SmartContract) RegisterElection

func (s *SmartContract) RegisterElection(ctx contractapi.TransactionContextInterface, election Election) error

RegisterElection registers election to world state. election is expected to be prepared by the backend.

func (*SmartContract) RegisterPoliticalParty

func (s *SmartContract) RegisterPoliticalParty(ctx contractapi.TransactionContextInterface, politicalParty PoliticalParty) error

RegisterPoliticalParty registers politicalparty to world state. politicalparty is expected to be prepared by the backend.

func (*SmartContract) RegisterVoter

func (s *SmartContract) RegisterVoter(ctx contractapi.TransactionContextInterface, voter Voter) error

RegisterVoter registers voter to world state. voter is expected to be prepared by the backend.

func (*SmartContract) UpdateCandidate

func (s *SmartContract) UpdateCandidate(ctx contractapi.TransactionContextInterface, key string, candidate Candidate) error

updateCandidate updates candidate from world state. candidate is expected to be prepared by the backend.

func (*SmartContract) UpdateElection

func (s *SmartContract) UpdateElection(ctx contractapi.TransactionContextInterface, key string, election Election) error

updateElection updates election from world state. election is expected to be prepared by the backend.

func (*SmartContract) UpdatePoliticalParty

func (s *SmartContract) UpdatePoliticalParty(ctx contractapi.TransactionContextInterface, politicalParty PoliticalParty) error

updatePoliticalParty updates politicalparty from world state. politicalparty is expected to be prepared by the backend.

func (*SmartContract) UpdateVoter

updateVoter updates voter from world state. voter is expected to be prepared by the backend.

type Voter

type Voter struct {
	Biodata             BioData
	VotedCandidateID    Candidate
	VoterPoliticalParty PoliticalParty
}

Voter struct. Voter is expected to be extended as demand requires.

func (Voter) HasBioData

func (v Voter) HasBioData() BioData

Jump to

Keyboard shortcuts

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