base

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: 28 Imported by: 0

Documentation

Overview

Package base has the fundamental modules and libraries to support consensus.

Index

Constants

View Source
const AddressTypeSize = 3
View Source
const MaxNetworkIDLength = 300

Variables

View Source
var (
	INITBallotType       = hint.Type("init-ballot")
	ProposalType         = hint.Type("proposal")
	ACCEPTBallotType     = hint.Type("accept-ballot")
	INITBallotFactType   = hint.Type("init-ballot-fact")
	ProposalFactType     = hint.Type("proposal-fact")
	ACCEPTBallotFactType = hint.Type("accept-ballot-fact")
)
View Source
var (
	BallotFactSignType   = hint.Type("ballot-fact-sign")
	BallotFactSignHint   = hint.NewHint(BallotFactSignType, "v0.0.1")
	BallotFactSignHinter = BaseBallotFactSign{BaseFactSign: BaseFactSign{
		BaseHinter: hint.NewBaseHinter(BallotFactSignHint),
	}}
	SignedBallotFactType   = hint.Type("signed-ballot-fact")
	SignedBallotFactHint   = hint.NewHint(SignedBallotFactType, "v0.0.1")
	SignedBallotFactHinter = BaseSignedBallotFact{BaseHinter: hint.NewBaseHinter(SignedBallotFactHint)}
)
View Source
var (
	BaseFactSignType   = hint.Type("base-fact-sign")
	BaseFactSignHint   = hint.NewHint(BaseFactSignType, "v0.0.1")
	BaseFactSignHinter = BaseFactSign{BaseHinter: hint.NewBaseHinter(BaseFactSignHint)}
)
View Source
var (
	NilHeight        = Height(-2)
	PreGenesisHeight = Height(-1)
	GenesisHeight    = Height(0)
)
View Source
var (
	StringAddressType   = hint.Type("sas")
	StringAddressHint   = hint.NewHint(StringAddressType, "v0.0.1")
	StringAddressHinter = StringAddress{/* contains filtered or unexported fields */}
)
View Source
var (
	MaxAddressSize = 100
	MinAddressSize = AddressTypeSize + 3

	REStringAddressString = `[a-zA-Z0-9][\w\-\.\!\$\*\@]*[a-zA-Z0-9]`
)
View Source
var (
	VoteproofV0Type   = hint.Type("voteproof")
	VoteproofV0Hint   = hint.NewHint(VoteproofV0Type, "v0.0.1")
	VoteproofV0Hinter = VoteproofV0{BaseHinter: hint.NewBaseHinter(VoteproofV0Hint)}
)

Functions

func CompareVoteproof

func CompareVoteproof(a, b Voteproof) int

func CompareVoteproofSamePoint

func CompareVoteproofSamePoint(a, b Voteproof) int

func FindMajority

func FindMajority(total, threshold uint, set ...uint) int

FindMajority finds the majority(over threshold) set between the given sets. The returned value means, 0-N: index number of set -1: not yet majority -2: draw

func IsValidBallotFactSign

func IsValidBallotFactSign(fact BallotFact, fs BallotFactSign, b []byte) error

func IsValidFactSign

func IsValidFactSign(fact Fact, fs FactSign, b []byte) error

func MarshalZerologFactSign

func MarshalZerologFactSign(fs FactSign) *zerolog.Event

func NewBytesForFactSignature

func NewBytesForFactSignature(fact Fact, b []byte) []byte

func NewFactSignature

func NewFactSignature(signer key.Privatekey, fact Fact, b []byte) (key.Signature, error)

func NumberOfFaultyNodes

func NumberOfFaultyNodes(n uint, threshold float64) int

func SortAddresses

func SortAddresses(as []Address)

Types

type ACCEPTBallot

type ACCEPTBallot interface {
	Ballot
	Fact() ACCEPTBallotFact
}

type ACCEPTBallotFact

type ACCEPTBallotFact interface {
	BallotFact
	Proposal() valuehash.Hash // NOTE fact hash of proposal ballot
	NewBlock() valuehash.Hash
}

type ActingSuffrage

type ActingSuffrage struct {
	// contains filtered or unexported fields
}

func NewActingSuffrage

func NewActingSuffrage(height Height, round Round, proposer Address, selected []Address) ActingSuffrage

func (ActingSuffrage) Exists

func (as ActingSuffrage) Exists(node Address) bool

func (ActingSuffrage) Height

func (as ActingSuffrage) Height() Height

func (ActingSuffrage) MarshalBSON

func (as ActingSuffrage) MarshalBSON() ([]byte, error)

func (ActingSuffrage) MarshalJSON

func (as ActingSuffrage) MarshalJSON() ([]byte, error)

func (ActingSuffrage) MarshalZerologObject

func (as ActingSuffrage) MarshalZerologObject(e *zerolog.Event)

func (ActingSuffrage) Nodes

func (as ActingSuffrage) Nodes() []Address

func (ActingSuffrage) Proposer

func (as ActingSuffrage) Proposer() Address

func (ActingSuffrage) Round

func (as ActingSuffrage) Round() Round

type ActingSuffragePacker

type ActingSuffragePacker struct {
	H Height    `json:"height" bson:"height"`
	R Round     `json:"round" bson:"round"`
	P string    `json:"proposer" bson:"proposer"`
	N []Address `json:"nodes" bson:"nodes"`
}

type Address

type Address interface {
	fmt.Stringer // NOTE String() should be typed string
	isvalid.IsValider
	hint.Hinter
	util.Byter
	Equal(Address) bool
}

Address represents the address of account.

func DecodeAddressFromString

func DecodeAddressFromString(s string, enc encoder.Encoder) (Address, error)

DecodeAddressFromString parses and decodes Address from string.

type AddressDecoder

type AddressDecoder struct {
	// contains filtered or unexported fields
}

func (*AddressDecoder) Encode

func (ad *AddressDecoder) Encode(enc encoder.Encoder) (Address, error)

func (*AddressDecoder) UnmarshalBSON

func (ad *AddressDecoder) UnmarshalBSON(b []byte) error

func (*AddressDecoder) UnmarshalJSON

func (ad *AddressDecoder) UnmarshalJSON(b []byte) error

type Ballot

type Ballot interface {
	zerolog.LogObjectMarshaler
	seal.Seal
	RawFact() BallotFact
	FactSign() BallotFactSign
	SignedFact() SignedBallotFact
	BaseVoteproof() Voteproof
	ACCEPTVoteproof() Voteproof
}

type BallotFact

type BallotFact interface {
	Fact
	Stage() Stage
	Height() Height
	Round() Round
}

type BallotFactSign

type BallotFactSign interface {
	FactSign
	Node() Address
}

type BaseBallotFactSign

type BaseBallotFactSign struct {
	BaseFactSign
	// contains filtered or unexported fields
}

func NewBaseBallotFactSign

func NewBaseBallotFactSign(n Address, pub key.Publickey, signedAt time.Time, sig key.Signature) BaseBallotFactSign

func NewBaseBallotFactSignFromFact

func NewBaseBallotFactSignFromFact(
	fact BallotFact,
	n Address,
	priv key.Privatekey,
	networkID NetworkID,
) (BaseBallotFactSign, error)

func (BaseBallotFactSign) Bytes

func (fs BaseBallotFactSign) Bytes() []byte

func (BaseBallotFactSign) IsValid

func (fs BaseBallotFactSign) IsValid([]byte) error

func (BaseBallotFactSign) MarshalBSON

func (fs BaseBallotFactSign) MarshalBSON() ([]byte, error)

func (BaseBallotFactSign) MarshalJSON

func (fs BaseBallotFactSign) MarshalJSON() ([]byte, error)

func (BaseBallotFactSign) MarshalZerologObject

func (fs BaseBallotFactSign) MarshalZerologObject(e *zerolog.Event)

func (BaseBallotFactSign) Node

func (fs BaseBallotFactSign) Node() Address

func (*BaseBallotFactSign) UnpackBSON

func (fs *BaseBallotFactSign) UnpackBSON(b []byte, enc *bsonenc.Encoder) error

func (*BaseBallotFactSign) UnpackJSON

func (fs *BaseBallotFactSign) UnpackJSON(b []byte, enc *jsonenc.Encoder) error

type BaseBallotFactSignNodeBSONUnpacker

type BaseBallotFactSignNodeBSONUnpacker struct {
	B  bson.Raw       `bson:"base"`
	NO AddressDecoder `bson:"node"`
}

type BaseBallotFactSignNodeJSONPacker

type BaseBallotFactSignNodeJSONPacker struct {
	NO Address `json:"node"`
}

type BaseBallotFactSignNodeJSONUnpacker

type BaseBallotFactSignNodeJSONUnpacker struct {
	NO AddressDecoder `json:"node"`
}

type BaseFactSign

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

func NewBaseFactSign

func NewBaseFactSign(signer key.Publickey, signature key.Signature) BaseFactSign

func NewBaseFactSignWithHint

func NewBaseFactSignWithHint(ht hint.Hint, signer key.Publickey, signature key.Signature) BaseFactSign

func RawBaseFactSign

func RawBaseFactSign(signer key.Publickey, signature key.Signature, signedAt time.Time) BaseFactSign

func (BaseFactSign) Bytes

func (fs BaseFactSign) Bytes() []byte

func (BaseFactSign) IsValid

func (fs BaseFactSign) IsValid([]byte) error

func (BaseFactSign) MarshalBSON

func (fs BaseFactSign) MarshalBSON() ([]byte, error)

func (BaseFactSign) MarshalJSON

func (fs BaseFactSign) MarshalJSON() ([]byte, error)

func (BaseFactSign) SetSignedAt

func (fs BaseFactSign) SetSignedAt(t time.Time) BaseFactSign

func (BaseFactSign) Signature

func (fs BaseFactSign) Signature() key.Signature

func (BaseFactSign) SignedAt

func (fs BaseFactSign) SignedAt() time.Time

func (BaseFactSign) Signer

func (fs BaseFactSign) Signer() key.Publickey

func (*BaseFactSign) UnpackBSON

func (fs *BaseFactSign) UnpackBSON(b []byte, enc *bsonenc.Encoder) error

func (*BaseFactSign) UnpackJSON

func (fs *BaseFactSign) UnpackJSON(b []byte, enc *jsonenc.Encoder) error

type BaseFactSignBSONUnpacker

type BaseFactSignBSONUnpacker struct {
	SN key.PublickeyDecoder `bson:"signer"`
	SG key.Signature        `bson:"signature"`
	SA time.Time            `bson:"signed_at"`
}

type BaseFactSignJSONPacker

type BaseFactSignJSONPacker struct {
	jsonenc.HintedHead
	SN key.Publickey  `json:"signer"`
	SG key.Signature  `json:"signature"`
	SA localtime.Time `json:"signed_at"`
}

type BaseFactSignJSONUnpacker

type BaseFactSignJSONUnpacker struct {
	SN key.PublickeyDecoder `json:"signer"`
	SG key.Signature        `json:"signature"`
	SA localtime.Time       `json:"signed_at"`
}

type BaseSignedBallotFact

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

func NewBaseSignedBallotFact

func NewBaseSignedBallotFact(fact BallotFact, factSign BallotFactSign) BaseSignedBallotFact

func NewBaseSignedBallotFactFromFact

func NewBaseSignedBallotFactFromFact(
	fact BallotFact,
	n Address,
	priv key.Privatekey,
	networkID NetworkID,
) (BaseSignedBallotFact, error)

func (BaseSignedBallotFact) Bytes

func (sfs BaseSignedBallotFact) Bytes() []byte

func (BaseSignedBallotFact) Fact

func (sfs BaseSignedBallotFact) Fact() BallotFact

func (BaseSignedBallotFact) FactSign

func (sfs BaseSignedBallotFact) FactSign() BallotFactSign

func (BaseSignedBallotFact) IsValid

func (sfs BaseSignedBallotFact) IsValid(networkID []byte) error

func (BaseSignedBallotFact) MarshalBSON

func (sfs BaseSignedBallotFact) MarshalBSON() ([]byte, error)

func (BaseSignedBallotFact) MarshalJSON

func (sfs BaseSignedBallotFact) MarshalJSON() ([]byte, error)

func (*BaseSignedBallotFact) UnpackBSON

func (sfs *BaseSignedBallotFact) UnpackBSON(b []byte, enc *bsonenc.Encoder) error

func (*BaseSignedBallotFact) UnpackJSON

func (sfs *BaseSignedBallotFact) UnpackJSON(b []byte, enc *jsonenc.Encoder) error

type BaseSignedBallotFactPackerJSON

type BaseSignedBallotFactPackerJSON struct {
	jsonenc.HintedHead
	FC BallotFact `json:"fact"`
	FS FactSign   `json:"fact_sign"`
}

type BaseSignedBallotFactUnpackBSON

type BaseSignedBallotFactUnpackBSON struct {
	FC bson.Raw `bson:"fact"`
	FS bson.Raw `bson:"fact_sign"`
}

type BaseSignedBallotFactUnpackJSON

type BaseSignedBallotFactUnpackJSON struct {
	FC json.RawMessage `json:"fact"`
	FS json.RawMessage `json:"fact_sign"`
}

type Fact

type Fact interface {
	isvalid.IsValider
	hint.Hinter
	valuehash.Hasher
}

type FactSign

type FactSign interface {
	util.Byter
	isvalid.IsValider
	hint.Hinter
	Signer() key.Publickey
	Signature() key.Signature
	SignedAt() time.Time
}

type FactSignUpdater

type FactSignUpdater interface {
	AddFactSigns(...FactSign) (FactSignUpdater, error)
}

type FixedSuffrage

type FixedSuffrage struct {
	*logging.Logging
	// contains filtered or unexported fields
}

FixedSuffrage will be used for creating genesis block or testing.

func NewFixedSuffrage

func NewFixedSuffrage(proposer Address, nodes []Address) *FixedSuffrage

func (*FixedSuffrage) Acting

func (ff *FixedSuffrage) Acting(height Height, round Round) (ActingSuffrage, error)

func (*FixedSuffrage) Initialize

func (ff *FixedSuffrage) Initialize() error

func (*FixedSuffrage) IsActing

func (ff *FixedSuffrage) IsActing(_ Height, _ Round, node Address) (bool, error)

func (*FixedSuffrage) IsInside

func (ff *FixedSuffrage) IsInside(a Address) bool

func (*FixedSuffrage) IsProposer

func (ff *FixedSuffrage) IsProposer(_ Height, _ Round, node Address) (bool, error)

func (*FixedSuffrage) Name

func (*FixedSuffrage) Name() string

func (*FixedSuffrage) Nodes

func (ff *FixedSuffrage) Nodes() []Address

func (*FixedSuffrage) NumberOfActing

func (*FixedSuffrage) NumberOfActing() uint

func (*FixedSuffrage) Verbose

func (ff *FixedSuffrage) Verbose() string

type Height

type Height int64

Height stands for height of Block

func NewHeightFromBytes

func NewHeightFromBytes(b []byte) (Height, error)

func NewHeightFromString

func NewHeightFromString(s string) (Height, error)

func (Height) Bytes

func (ht Height) Bytes() []byte

func (Height) Int64

func (ht Height) Int64() int64

Int64 returns int64 of height.

func (Height) IsEmpty

func (ht Height) IsEmpty() bool

func (Height) IsValid

func (ht Height) IsValid([]byte) error

IsValid checks Height.

func (Height) String

func (ht Height) String() string

type INITBallot

type INITBallot interface {
	Ballot
	Fact() INITBallotFact
}

type INITBallotFact

type INITBallotFact interface {
	BallotFact
	PreviousBlock() valuehash.Hash
}

type NetworkID

type NetworkID []byte

NetworkID will be used to separate mitum network with the other network. For exampke, with different NetworkID, same Seal messsage will have different hash.

func (NetworkID) Bytes

func (ni NetworkID) Bytes() []byte

func (NetworkID) Equal

func (ni NetworkID) Equal(a NetworkID) bool

func (NetworkID) IsValid

func (ni NetworkID) IsValid([]byte) error

func (NetworkID) MarshalText

func (ni NetworkID) MarshalText() ([]byte, error)

func (*NetworkID) UnmarshalText

func (ni *NetworkID) UnmarshalText(b []byte) error

type Node

type Node interface {
	fmt.Stringer
	isvalid.IsValider
	hint.Hinter
	Address() Address
	Publickey() key.Publickey
}

type Proposal

type Proposal interface {
	Ballot
	Fact() ProposalFact
}

type ProposalFact

type ProposalFact interface {
	BallotFact
	Proposer() Address
	Operations() []valuehash.Hash
	ProposedAt() time.Time
}

type Round

type Round uint64

Round is used to vote by ballot.

func (Round) Bytes

func (rn Round) Bytes() []byte

func (Round) Uint64

func (rn Round) Uint64() uint64

Uint64 returns int64 of height.

type SignWithFacter

type SignWithFacter interface {
	Sign(key.Privatekey, []byte) error
	SignWithFact(Address, key.Privatekey, []byte) error
}

type SignedBallotFact

type SignedBallotFact interface {
	hint.Hinter
	isvalid.IsValider
	util.Byter
	Fact() BallotFact
	FactSign() BallotFactSign
}

type Stage

type Stage uint8
const (
	StageINIT Stage
	StageProposal
	StageACCEPT
)

func (Stage) Bytes

func (st Stage) Bytes() []byte

func (Stage) CanVote

func (st Stage) CanVote() bool

func (Stage) IsValid

func (st Stage) IsValid([]byte) error

func (Stage) MarshalText

func (st Stage) MarshalText() ([]byte, error)

func (Stage) String

func (st Stage) String() string

func (*Stage) UnmarshalText

func (st *Stage) UnmarshalText(b []byte) error

type State

type State uint8
const (
	StateEmpty State = iota
	// StateStopped indicates node is in state, node process is
	// finished.
	StateStopped
	// StateBooting indicates node is in state, node checks it's state.
	StateBooting
	// StateJoining indicates node is in state, node is trying to
	// join consensus.
	StateJoining
	// StateConsensus indicates node is in state, node participates
	// consensus with the other nodes.
	StateConsensus
	// StateSyncing indicates node is in state, node is syncing block.
	StateSyncing
	// StateBroken indicates that node can not participates network
	// with various kind of reason.
	StateBroken
	// StateHandover indicates that node tries to replace the existing same node
	StateHandover
)

func StateFromString

func StateFromString(s string) (State, error)

func (State) Bytes

func (st State) Bytes() []byte

func (State) IsValid

func (st State) IsValid([]byte) error

func (State) MarshalText

func (st State) MarshalText() ([]byte, error)

func (State) String

func (st State) String() string

func (*State) UnmarshalText

func (st *State) UnmarshalText(b []byte) error

type StringAddress

type StringAddress struct {
	// contains filtered or unexported fields
}

func MustNewStringAddress

func MustNewStringAddress(s string) StringAddress

func NewStringAddress

func NewStringAddress(s string) StringAddress

func NewStringAddressWithHint

func NewStringAddressWithHint(ht hint.Hint, s string) StringAddress

func ParseStringAddress

func ParseStringAddress(s string) (StringAddress, error)

func (StringAddress) Bytes

func (ad StringAddress) Bytes() []byte

func (StringAddress) Equal

func (ad StringAddress) Equal(b Address) bool

func (StringAddress) Hint

func (ad StringAddress) Hint() hint.Hint

func (StringAddress) IsValid

func (ad StringAddress) IsValid([]byte) error

func (StringAddress) MarshalBSONValue

func (ad StringAddress) MarshalBSONValue() (bsontype.Type, []byte, error)

func (StringAddress) MarshalText

func (ad StringAddress) MarshalText() ([]byte, error)

func (StringAddress) SetHint

func (ad StringAddress) SetHint(ht hint.Hint) hint.Hinter

func (StringAddress) String

func (ad StringAddress) String() string

func (*StringAddress) UnpackBSON

func (ad *StringAddress) UnpackBSON(b []byte, _ *bsonenc.Encoder) error

func (*StringAddress) UnpackJSON

func (ad *StringAddress) UnpackJSON(b []byte, _ *jsonenc.Encoder) error

type Suffrage

type Suffrage interface {
	util.Initializer
	Name() string
	NumberOfActing() uint
	Acting(Height, Round) (ActingSuffrage, error)
	IsInside(Address) bool
	IsActing(Height, Round, Address) (bool, error)
	IsProposer(Height, Round, Address) (bool, error)
	Nodes() []Address
	Verbose() string
}

type Threshold

type Threshold struct {
	Total     uint           `json:"total" bson:"total"`
	Threshold uint           `json:"threshold" bson:"threshold"`
	Ratio     ThresholdRatio `json:"ratio" bson:"ratio"` // NOTE 67.0 ~ 100.0
}

func MustNewThreshold

func MustNewThreshold(total uint, ratio ThresholdRatio) Threshold

func NewThreshold

func NewThreshold(total uint, ratio ThresholdRatio) (Threshold, error)

func (Threshold) Bytes

func (thr Threshold) Bytes() []byte

func (Threshold) Equal

func (thr Threshold) Equal(b Threshold) bool

func (Threshold) IsValid

func (thr Threshold) IsValid([]byte) error

func (Threshold) String

func (thr Threshold) String() string

type ThresholdRatio

type ThresholdRatio float64

func (ThresholdRatio) Float64

func (tr ThresholdRatio) Float64() float64

func (ThresholdRatio) IsValid

func (tr ThresholdRatio) IsValid([]byte) error

type VoteResultType

type VoteResultType uint8
const (
	VoteResultNotYet VoteResultType = iota
	VoteResultDraw
	VoteResultMajority
)

func FindMajorityFromSlice

func FindMajorityFromSlice(total, threshold uint, s []string) (VoteResultType, string)

func (VoteResultType) Bytes

func (vrt VoteResultType) Bytes() []byte

func (VoteResultType) IsValid

func (vrt VoteResultType) IsValid([]byte) error

func (VoteResultType) MarshalText

func (vrt VoteResultType) MarshalText() ([]byte, error)

func (VoteResultType) String

func (vrt VoteResultType) String() string

func (*VoteResultType) UnmarshalText

func (vrt *VoteResultType) UnmarshalText(b []byte) error

type Voteproof

type Voteproof interface {
	hint.Hinter
	isvalid.IsValider
	util.Byter
	zerolog.LogObjectMarshaler
	ID() string // ID is only unique in local machine
	IsFinished() bool
	FinishedAt() time.Time
	IsClosed() bool
	Height() Height
	Round() Round
	Stage() Stage
	Result() VoteResultType
	Majority() BallotFact
	Facts() []BallotFact
	Votes() []SignedBallotFact
	ThresholdRatio() ThresholdRatio
	Suffrages() []Address
}

type VoteproofSet

type VoteproofSet struct {
	Voteproof
	// contains filtered or unexported fields
}

VoteproofSet has voteproofs of Ballot, it will be used to deliver multiple voteproofs at once.

func NewVoteproofSet

func NewVoteproofSet(bvp, avp Voteproof) VoteproofSet

func (VoteproofSet) ACCEPTVoteproof

func (vp VoteproofSet) ACCEPTVoteproof() Voteproof

type VoteproofV0

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

func EmptyVoteproofV0

func EmptyVoteproofV0() VoteproofV0

func NewVoteproofV0

func NewVoteproofV0(
	height Height,
	round Round,
	suffrages []Address,
	thresholdRatio ThresholdRatio,
	stage Stage,
) VoteproofV0

func (VoteproofV0) Bytes

func (vp VoteproofV0) Bytes() []byte

func (*VoteproofV0) Close

func (vp *VoteproofV0) Close() *VoteproofV0

func (VoteproofV0) Facts

func (vp VoteproofV0) Facts() []BallotFact

func (*VoteproofV0) Finish

func (vp *VoteproofV0) Finish() *VoteproofV0

func (VoteproofV0) FinishedAt

func (vp VoteproofV0) FinishedAt() time.Time

func (VoteproofV0) Height

func (vp VoteproofV0) Height() Height

func (VoteproofV0) ID

func (vp VoteproofV0) ID() string

func (VoteproofV0) IsClosed

func (vp VoteproofV0) IsClosed() bool

func (VoteproofV0) IsFinished

func (vp VoteproofV0) IsFinished() bool

func (VoteproofV0) IsValid

func (vp VoteproofV0) IsValid(networkID []byte) error

func (VoteproofV0) Majority

func (vp VoteproofV0) Majority() BallotFact

func (VoteproofV0) MarshalBSON

func (vp VoteproofV0) MarshalBSON() ([]byte, error)

func (VoteproofV0) MarshalJSON

func (vp VoteproofV0) MarshalJSON() ([]byte, error)

func (VoteproofV0) MarshalZerologObject

func (vp VoteproofV0) MarshalZerologObject(e *zerolog.Event)

func (VoteproofV0) Result

func (vp VoteproofV0) Result() VoteResultType

func (VoteproofV0) Round

func (vp VoteproofV0) Round() Round

func (*VoteproofV0) SetFacts

func (vp *VoteproofV0) SetFacts(facts []BallotFact) *VoteproofV0

func (*VoteproofV0) SetMajority

func (vp *VoteproofV0) SetMajority(fact BallotFact) *VoteproofV0

func (*VoteproofV0) SetResult

func (vp *VoteproofV0) SetResult(result VoteResultType) *VoteproofV0

func (*VoteproofV0) SetVotes

func (vp *VoteproofV0) SetVotes(votes []SignedBallotFact) *VoteproofV0

func (VoteproofV0) Stage

func (vp VoteproofV0) Stage() Stage

func (VoteproofV0) Suffrages

func (vp VoteproofV0) Suffrages() []Address

func (VoteproofV0) ThresholdRatio

func (vp VoteproofV0) ThresholdRatio() ThresholdRatio

func (*VoteproofV0) UnpackBSON

func (vp *VoteproofV0) UnpackBSON(b []byte, enc *bsonenc.Encoder) error

func (*VoteproofV0) UnpackJSON

func (vp *VoteproofV0) UnpackJSON(b []byte, enc *jsonenc.Encoder) error

func (VoteproofV0) Votes

func (vp VoteproofV0) Votes() []SignedBallotFact

type VoteproofV0BallotBSONPacker

type VoteproofV0BallotBSONPacker struct {
	H valuehash.Hash
	A Address
}

type VoteproofV0BallotBSONUnpacker

type VoteproofV0BallotBSONUnpacker struct {
	H valuehash.Bytes
	A bson.Raw
}

func (VoteproofV0BallotBSONUnpacker) Address

func (vv VoteproofV0BallotBSONUnpacker) Address() []byte

func (VoteproofV0BallotBSONUnpacker) Hash

type VoteproofV0BallotJSONPacker

type VoteproofV0BallotJSONPacker struct {
	H valuehash.Hash
	A Address
}

type VoteproofV0BallotJSONUnpacker

type VoteproofV0BallotJSONUnpacker struct {
	H valuehash.Bytes
	A json.RawMessage
}

func (VoteproofV0BallotJSONUnpacker) Address

func (vv VoteproofV0BallotJSONUnpacker) Address() []byte

func (VoteproofV0BallotJSONUnpacker) Hash

type VoteproofV0BallotUnpacker

type VoteproofV0BallotUnpacker interface {
	Hash() valuehash.Bytes
	Address() []byte
}

type VoteproofV0FactBSONPacker

type VoteproofV0FactBSONPacker struct {
	H valuehash.Hash
	F Fact
}

type VoteproofV0FactBSONUnpacker

type VoteproofV0FactBSONUnpacker struct {
	H valuehash.Bytes
	F bson.Raw
}

func (VoteproofV0FactBSONUnpacker) Fact

func (vv VoteproofV0FactBSONUnpacker) Fact() []byte

func (VoteproofV0FactBSONUnpacker) Hash

type VoteproofV0FactJSONPacker

type VoteproofV0FactJSONPacker struct {
	H valuehash.Hash
	F Fact
}

type VoteproofV0FactJSONUnpacker

type VoteproofV0FactJSONUnpacker struct {
	H valuehash.Bytes
	F json.RawMessage
}

func (VoteproofV0FactJSONUnpacker) Fact

func (vv VoteproofV0FactJSONUnpacker) Fact() []byte

func (VoteproofV0FactJSONUnpacker) Hash

type VoteproofV0FactUnpacker

type VoteproofV0FactUnpacker interface {
	Hash() valuehash.Bytes
	Fact() []byte
}

type VoteproofV0PackJSON

type VoteproofV0PackJSON struct {
	jsonenc.HintedHead
	HT Height             `json:"height"`
	RD Round              `json:"round"`
	SS []Address          `json:"suffrages"`
	TH ThresholdRatio     `json:"threshold"`
	RS VoteResultType     `json:"result"`
	ST Stage              `json:"stage"`
	MJ BallotFact         `json:"majority"`
	FS []BallotFact       `json:"facts"`
	VS []SignedBallotFact `json:"votes"`
	FA localtime.Time     `json:"finished_at"`
	CL string             `json:"is_closed"`
}

type VoteproofV0UnpackBSON

type VoteproofV0UnpackBSON struct {
	HT Height           `bson:"height"`
	RD Round            `bson:"round"`
	SS []AddressDecoder `bson:"suffrages"`
	TH ThresholdRatio   `bson:"threshold"`
	RS VoteResultType   `bson:"result"`
	ST Stage            `bson:"stage"`
	MJ bson.Raw         `bson:"majority"`
	FS bson.Raw         `bson:"facts"`
	VS bson.Raw         `bson:"votes"`
	FA time.Time        `bson:"finished_at"`
	CL bool             `bson:"is_closed"`
}

type VoteproofV0UnpackJSON

type VoteproofV0UnpackJSON struct {
	HT Height           `json:"height"`
	RD Round            `json:"round"`
	SS []AddressDecoder `json:"suffrages"`
	TH ThresholdRatio   `json:"threshold"`
	RS VoteResultType   `json:"result"`
	ST Stage            `json:"stage"`
	MJ json.RawMessage  `json:"majority"`
	FS json.RawMessage  `json:"facts"`
	VS json.RawMessage  `json:"votes"`
	FA localtime.Time   `json:"finished_at"`
	CL string           `json:"is_closed"`
}

Directories

Path Synopsis
Package ballot contains ballot seals for consensus
Package ballot contains ballot seals for consensus
Package block defines Block and it's relatives.
Package block defines Block and it's relatives.
Package key provides keypairs.
Package key provides keypairs.
Package node provides several Node types.
Package node provides several Node types.
Package operation is the collection of Operations.
Package operation is the collection of Operations.
Package prprocessor provides the processor of operations
Package prprocessor provides the processor of operations
Package seal is the basic form of message.
Package seal is the basic form of message.
Package state holds data and it's state
Package state holds data and it's state

Jump to

Keyboard shortcuts

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