ballot

package
v0.0.0-...-5a6e01e Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package ballot contains ballot seals for consensus

Index

Constants

This section is empty.

Variables

View Source
var (
	ACCEPTFactHint   = hint.NewHint(base.ACCEPTBallotFactType, "v0.0.1")
	ACCEPTFactHinter = ACCEPTFact{BaseFact: BaseFact{BaseHinter: hint.NewBaseHinter(ACCEPTFactHint)}}
	ACCEPTHint       = hint.NewHint(base.ACCEPTBallotType, "v0.0.1")
	ACCEPTHinter     = ACCEPT{BaseSeal: BaseSeal{BaseSeal: seal.NewBaseSealWithHint(ACCEPTHint)}}
)
View Source
var (
	INITFactHint   = hint.NewHint(base.INITBallotFactType, "v0.0.1")
	INITFactHinter = INITFact{BaseFact: BaseFact{BaseHinter: hint.NewBaseHinter(INITFactHint)}}
	INITHint       = hint.NewHint(base.INITBallotType, "v0.0.1")
	INITHinter     = INIT{BaseSeal: BaseSeal{BaseSeal: seal.NewBaseSealWithHint(INITHint)}}
)
View Source
var (
	ProposalFactHint   = hint.NewHint(base.ProposalFactType, "v0.0.1")
	ProposalFactHinter = ProposalFact{BaseFact: BaseFact{BaseHinter: hint.NewBaseHinter(ProposalFactHint)}}
	ProposalHint       = hint.NewHint(base.ProposalType, "v0.0.1")
	ProposalHinter     = Proposal{BaseSeal: BaseSeal{BaseSeal: seal.NewBaseSealWithHint(ProposalHint)}}
)

Functions

This section is empty.

Types

type ACCEPT

type ACCEPT struct {
	BaseSeal
}

func NewACCEPT

func NewACCEPT(
	fact ACCEPTFact,
	n base.Address,
	baseVoteproof base.Voteproof,
	pk key.Privatekey,
	networkID base.NetworkID,
) (ACCEPT, error)

func (ACCEPT) Fact

func (sl ACCEPT) Fact() base.ACCEPTBallotFact

func (ACCEPT) IsValid

func (sl ACCEPT) IsValid(networkID []byte) error

type ACCEPTFact

type ACCEPTFact struct {
	BaseFact
	// contains filtered or unexported fields
}

func NewACCEPTFact

func NewACCEPTFact(
	height base.Height,
	round base.Round,
	proposal,
	newBlock valuehash.Hash,
) ACCEPTFact

func (ACCEPTFact) IsValid

func (fact ACCEPTFact) IsValid([]byte) error

func (ACCEPTFact) MarshalBSON

func (fact ACCEPTFact) MarshalBSON() ([]byte, error)

func (ACCEPTFact) MarshalJSON

func (fact ACCEPTFact) MarshalJSON() ([]byte, error)

func (ACCEPTFact) NewBlock

func (fact ACCEPTFact) NewBlock() valuehash.Hash

func (ACCEPTFact) Proposal

func (fact ACCEPTFact) Proposal() valuehash.Hash

func (*ACCEPTFact) UnpackBSON

func (fact *ACCEPTFact) UnpackBSON(b []byte, enc *bsonenc.Encoder) error

func (*ACCEPTFact) UnpackJSON

func (fact *ACCEPTFact) UnpackJSON(b []byte, enc *jsonenc.Encoder) error

type ACCEPTFactPackerJSON

type ACCEPTFactPackerJSON struct {
	P  valuehash.Hash `json:"proposal"`
	NB valuehash.Hash `json:"new_block"`
}

type ACCEPTFactUnpackerBSON

type ACCEPTFactUnpackerBSON struct {
	P valuehash.Bytes `bson:"proposal"`
	N valuehash.Bytes `bson:"new_block"`
}

type ACCEPTFactUnpackerJSON

type ACCEPTFactUnpackerJSON struct {
	P  valuehash.Bytes `json:"proposal"`
	NB valuehash.Bytes `json:"new_block"`
}

type BaseBallotPackerJSON

type BaseBallotPackerJSON struct {
	F  base.SignedBallotFact `json:"signed_fact"`
	BB base.Voteproof        `json:"base_voteproof"`
	BA base.Voteproof        `json:"accept_voteproof,omitempty"`
}

type BaseBallotUnpackerBSON

type BaseBallotUnpackerBSON struct {
	F  bson.Raw `bson:"signed_fact"`
	BB bson.Raw `bson:"base_voteproof"`
	BA bson.Raw `bson:"accept_voteproof,omitempty"`
}

type BaseBallotUnpackerJSON

type BaseBallotUnpackerJSON struct {
	F  json.RawMessage `json:"signed_fact"`
	BB json.RawMessage `json:"base_voteproof"`
	BA json.RawMessage `json:"accept_voteproof,omitempty"`
}

type BaseFact

type BaseFact struct {
	hint.BaseHinter
	// contains filtered or unexported fields
}

func NewBaseFact

func NewBaseFact(ht hint.Hint, height base.Height, round base.Round) BaseFact

func (BaseFact) Hash

func (fact BaseFact) Hash() valuehash.Hash

func (BaseFact) Height

func (fact BaseFact) Height() base.Height

func (BaseFact) IsValid

func (fact BaseFact) IsValid([]byte) error

func (BaseFact) Round

func (fact BaseFact) Round() base.Round

func (BaseFact) Stage

func (fact BaseFact) Stage() base.Stage

type BaseFactPackerJSON

type BaseFactPackerJSON struct {
	jsonenc.HintedHead
	H  valuehash.Hash `json:"hash"`
	HT base.Height    `json:"height"`
	R  base.Round     `json:"round"`
}

type BaseFactUnpackerBSON

type BaseFactUnpackerBSON struct {
	HI hint.Hint       `json:"_hint"`
	H  valuehash.Bytes `bson:"hash"`
	HT base.Height     `bson:"height"`
	R  base.Round      `bson:"round"`
}

type BaseFactUnpackerJSON

type BaseFactUnpackerJSON struct {
	HI hint.Hint       `json:"_hint"`
	H  valuehash.Bytes `json:"hash"`
	HT base.Height     `json:"height"`
	R  base.Round      `json:"round"`
}

type BaseSeal

type BaseSeal struct {
	seal.BaseSeal
	// contains filtered or unexported fields
}

func NewBaseSeal

func NewBaseSeal(
	ht hint.Hint,
	fact base.BallotFact,
	n base.Address,
	baseVoteproof base.Voteproof,
	acceptVoteproof base.Voteproof,
	pk key.Privatekey,
	networkID base.NetworkID,
) (BaseSeal, error)

func (BaseSeal) ACCEPTVoteproof

func (sl BaseSeal) ACCEPTVoteproof() base.Voteproof

func (BaseSeal) BaseVoteproof

func (sl BaseSeal) BaseVoteproof() base.Voteproof

func (BaseSeal) BodyBytes

func (sl BaseSeal) BodyBytes() []byte

func (BaseSeal) FactSign

func (sl BaseSeal) FactSign() base.BallotFactSign

func (BaseSeal) IsValid

func (sl BaseSeal) IsValid(networkID []byte) error

func (BaseSeal) MarshalBSON

func (sl BaseSeal) MarshalBSON() ([]byte, error)

func (BaseSeal) MarshalJSON

func (sl BaseSeal) MarshalJSON() ([]byte, error)

func (BaseSeal) MarshalZerologObject

func (sl BaseSeal) MarshalZerologObject(e *zerolog.Event)

func (BaseSeal) RawFact

func (sl BaseSeal) RawFact() base.BallotFact

func (*BaseSeal) SignWithFact

func (sl *BaseSeal) SignWithFact(n base.Address, priv key.Privatekey, networkID []byte) error

func (BaseSeal) SignedFact

func (sl BaseSeal) SignedFact() base.SignedBallotFact

func (*BaseSeal) UnpackBSON

func (sl *BaseSeal) UnpackBSON(b []byte, enc *bsonenc.Encoder) error

func (*BaseSeal) UnpackJSON

func (sl *BaseSeal) UnpackJSON(b []byte, enc *jsonenc.Encoder) error

type INIT

type INIT struct {
	BaseSeal
}

func NewINIT

func NewINIT(
	fact INITFact,
	n base.Address,
	baseVoteproof base.Voteproof,
	acceptVoteproof base.Voteproof,
	pk key.Privatekey,
	networkID base.NetworkID,
) (INIT, error)

func (INIT) ACCEPTVoteproof

func (sl INIT) ACCEPTVoteproof() base.Voteproof

func (INIT) Fact

func (sl INIT) Fact() base.INITBallotFact

func (INIT) IsValid

func (sl INIT) IsValid(networkID []byte) error

type INITFact

type INITFact struct {
	BaseFact
	// contains filtered or unexported fields
}

func NewINITFact

func NewINITFact(
	height base.Height,
	round base.Round,
	previousBlock valuehash.Hash,
) INITFact

func (INITFact) IsValid

func (fact INITFact) IsValid([]byte) error

func (INITFact) MarshalBSON

func (fact INITFact) MarshalBSON() ([]byte, error)

func (INITFact) MarshalJSON

func (fact INITFact) MarshalJSON() ([]byte, error)

func (INITFact) PreviousBlock

func (fact INITFact) PreviousBlock() valuehash.Hash

func (*INITFact) UnpackBSON

func (fact *INITFact) UnpackBSON(b []byte, enc *bsonenc.Encoder) error

func (*INITFact) UnpackJSON

func (fact *INITFact) UnpackJSON(b []byte, enc *jsonenc.Encoder) error

type INITFactPackerJSON

type INITFactPackerJSON struct {
	P valuehash.Hash `json:"previous_block"`
}

type INITFactUnpackerBSON

type INITFactUnpackerBSON struct {
	P valuehash.Bytes `bson:"previous_block"`
}

type INITFactUnpackerJSON

type INITFactUnpackerJSON struct {
	P valuehash.Bytes `json:"previous_block"`
}

type Proposal

type Proposal struct {
	BaseSeal
}

func NewProposal

func NewProposal(
	fact ProposalFact,
	n base.Address,
	baseVoteproof base.Voteproof,
	pk key.Privatekey,
	networkID base.NetworkID,
) (Proposal, error)

func (Proposal) Fact

func (sl Proposal) Fact() base.ProposalFact

func (Proposal) IsValid

func (sl Proposal) IsValid(networkID []byte) error

type ProposalFact

type ProposalFact struct {
	BaseFact
	// contains filtered or unexported fields
}

func NewProposalFact

func NewProposalFact(
	height base.Height,
	round base.Round,
	proposer base.Address,
	ops []valuehash.Hash,
) ProposalFact

func (ProposalFact) IsValid

func (fact ProposalFact) IsValid([]byte) error

func (ProposalFact) MarshalBSON

func (fact ProposalFact) MarshalBSON() ([]byte, error)

func (ProposalFact) MarshalJSON

func (fact ProposalFact) MarshalJSON() ([]byte, error)

func (ProposalFact) Operations

func (fact ProposalFact) Operations() []valuehash.Hash

func (ProposalFact) ProposedAt

func (fact ProposalFact) ProposedAt() time.Time

func (ProposalFact) Proposer

func (fact ProposalFact) Proposer() base.Address

func (*ProposalFact) UnpackBSON

func (fact *ProposalFact) UnpackBSON(b []byte, enc *bsonenc.Encoder) error

func (*ProposalFact) UnpackJSON

func (fact *ProposalFact) UnpackJSON(b []byte, enc *jsonenc.Encoder) error

type ProposalFactPackerJSON

type ProposalFactPackerJSON struct {
	PR  base.Address     `json:"proposer"`
	OPS []valuehash.Hash `json:"operations"`
	PA  localtime.Time   `json:"proposed_at"`
}

type ProposalFactUnpackerBSON

type ProposalFactUnpackerBSON struct {
	PR  base.AddressDecoder `bson:"proposer"`
	OPS []valuehash.Bytes   `bson:"operations"`
	PA  time.Time           `bson:"proposed_at"`
}

type ProposalFactUnpackerJSON

type ProposalFactUnpackerJSON struct {
	PR  base.AddressDecoder `json:"proposer"`
	OPS []valuehash.Bytes   `json:"operations"`
	PA  localtime.Time      `json:"proposed_at"`
}

Jump to

Keyboard shortcuts

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