isaac

package
v0.0.0-...-b559f02 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: GPL-3.0 Imports: 35 Imported by: 11

Documentation

Overview

Package isaac runs consensus process

Index

Constants

This section is empty.

Variables

View Source
var (
	INITBallotHint   = hint.MustNewHint("init-ballot-v0.0.1")
	ACCEPTBallotHint = hint.MustNewHint("accept-ballot-v0.0.1")
)
View Source
var (
	INITBallotFactHint                  = hint.MustNewHint("init-ballot-fact-v0.0.1")
	ACCEPTBallotFactHint                = hint.MustNewHint("accept-ballot-fact-v0.0.1")
	SuffrageConfirmBallotFactHint       = hint.MustNewHint("suffrage-confirm-ballot-fact-v0.0.1")
	EmptyProposalINITBallotFactHint     = hint.MustNewHint("empty-proposal-init-ballot-fact-v0.0.1")
	EmptyOperationsACCEPTBallotFactHint = hint.MustNewHint("empty-operations-accept-ballot-fact-v0.0.1")
	NotProcessedACCEPTBallotFactHint    = hint.MustNewHint("not-processed-accept-ballot-fact-v0.0.1")
)
View Source
var (
	INITBallotSignFactHint   = hint.MustNewHint("init-ballot-sign-fact-v0.0.1")
	ACCEPTBallotSignFactHint = hint.MustNewHint("accept-ballot-sign-fact-v0.0.1")
)
View Source
var (
	ManifestHint       = hint.MustNewHint("manifest-v0.0.1")
	BlockItemFileHint  = hint.MustNewHint("block-item-file-v0.0.1")
	BlockItemFilesHint = hint.MustNewHint("block-item-files-v0.0.1")
)
View Source
var (
	NetworkPolicyHint           = hint.MustNewHint("network-policy-v0.0.1")
	NetworkPolicyStateValueHint = hint.MustNewHint("network-policy-state-value-v0.0.1")

	DefaultMaxOperationsInProposal uint64 = 333
	DefaultMaxSuffrageSize         uint64 = 33

	// NOTE suffrage candidate can be approved within lifespan height; almost 15
	// days(based on 5 second for one block)
	DefaultSuffrageCandidateLifespan base.Height = 1 << 18
	DefaultSuffrageExpelLifespan                 = base.Height(333) //nolint:gomnd //...
	DefaultEmptyProposalNoBlock                  = false
)
View Source
var (
	DefaultntervalBroadcastBallot     = time.Second * 3
	DefaultWaitPreparingINITBallot    = time.Second * 5
	DefaultWaitStuckInterval          = time.Second * 33
	DefaultTimeoutRequest             = time.Second * 3
	DefaultMinWaitNextBlockINITBallot = time.Second * 2
	DefaultStateCacheSize             = 1 << 12
	DefaultOperationPoolCacheSize     = 1 << 12
)
View Source
var (
	ProposalFactHint     = hint.MustNewHint("proposal-fact-v0.0.1")
	ProposalSignFactHint = hint.MustNewHint("proposal-sign-fact-v0.0.1")
)
View Source
var (
	ErrOperationInProcessorNotFound         = util.NewIDError("operation processor not found")
	ErrInvalidOperationInProcessor          = util.NewIDError("invalid operation")
	ErrOperationNotFoundInProcessor         = util.NewIDError("operation not found")
	ErrOperationAlreadyProcessedInProcessor = util.NewIDError("operation already processed")
	ErrSuspendOperation                     = util.NewIDError("suspend operation")
	ErrProcessorAlreadySaved                = util.NewIDError("processor already saved")
	ErrProposalProcessorEmptyOperations     = util.NewIDError("empty operations in proposal")
)
View Source
var (
	ErrIgnoreErrorProposalProcessor  = util.NewIDError("proposal processor somthing wrong; ignore")
	ErrNotProposalProcessorProcessed = util.NewIDError("proposal processor not processed")
)

ErrIgnoreErrorProposalProcessor ignores error from proposalProcessor, it means not ErrIgnoreErrorProposalProcessor from proposalProcessor will break consensus.

View Source
var (
	LocalFSBlockItemScheme     = "local"
	BlockDirectoryHeightFormat = "%021s"
)
View Source
var (
	DefaultBlockItemReadersRemoveEmptyAfter    = time.Minute * 9
	DefaultBlockItemReadersRemoveEmptyInterval = time.Minute * 3
)
View Source
var (
	FixedSuffrageCandidateLimiterRuleHint    = hint.MustNewHint("fixed-suffrage-candidate-limiter-rule-v0.0.1")
	MajoritySuffrageCandidateLimiterRuleHint = hint.MustNewHint("majority-suffrage-candidate-limiter-rule-v0.0.1")
)
View Source
var (
	SuffrageExpelFactHint      = hint.MustNewHint("suffrage-expel-fact-v0.0.1")
	SuffrageExpelOperationHint = hint.MustNewHint("suffrage-expel-operation-v0.0.1")
)
View Source
var (
	SuffrageNodeStateValueHint       = hint.MustNewHint("suffrage-node-state-value-v0.0.1")
	SuffrageNodesStateValueHint      = hint.MustNewHint("suffrage-nodes-state-value-v0.0.1")
	SuffrageCandidateStateValueHint  = hint.MustNewHint("suffrage-candidate-state-value-v0.0.1")
	SuffrageCandidatesStateValueHint = hint.MustNewHint("suffrage-candidates-state-value-v0.0.1")
)
View Source
var (
	SuffrageStateKey          = "suffrage"
	SuffrageCandidateStateKey = "suffrage_candidate"
	NetworkPolicyStateKey     = "network_policy"
)
View Source
var (
	ErrEmptySyncSources = util.NewIDError("empty sync sources; will retry")
	ErrRetrySyncSources = util.NewIDError("sync sources problem; will retry")
)
View Source
var (
	INITVoteproofHint        = hint.MustNewHint("init-voteproof-v0.0.1")
	INITExpelVoteproofHint   = hint.MustNewHint("init-expel-voteproof-v0.0.1")
	INITStuckVoteproofHint   = hint.MustNewHint("init-stuck-voteproof-v0.0.1")
	ACCEPTVoteproofHint      = hint.MustNewHint("accept-voteproof-v0.0.1")
	ACCEPTExpelVoteproofHint = hint.MustNewHint("accept-expel-voteproof-v0.0.1")
	ACCEPTStuckVoteproofHint = hint.MustNewHint("accept-stuck-voteproof-v0.0.1")
)
View Source
var HTTPInsecureFlag = "https_insecure"
View Source
var NodeHint = hint.MustNewHint("node-v0.0.1")
View Source
var ParamsHint = hint.MustNewHint("isaac-params-v0.0.1")

Functions

func BlockHeightDirectory

func BlockHeightDirectory(height base.Height) string

func BlockItemDecodeLineItems

func BlockItemDecodeLineItems(
	f io.Reader,
	decode func([]byte) (interface{}, error),
	callback func(uint64, interface{}) error,
) (count uint64, _ error)

func BlockItemDecodeLineItemsWithWorker

func BlockItemDecodeLineItemsWithWorker(
	f io.Reader,
	num uint64,
	decode func([]byte) (interface{}, error),
	callback func(uint64, interface{}) error,
) (count uint64, _ error)

func BlockItemFilesPath

func BlockItemFilesPath(root string, height base.Height) string

func BlockItemReadersDecode

func BlockItemReadersDecode[T any](
	itemf BlockItemReadersItemFunc,
	height base.Height,
	t base.BlockItemType,
	f func(ir BlockItemReader) error,
) (target T, _ bool, _ error)

func BlockItemReadersDecodeFromReader

func BlockItemReadersDecodeFromReader[T any](
	itemf BlockItemReadersFromReaderFunc,
	t base.BlockItemType,
	r io.Reader,
	compressFormat string,
	f func(ir BlockItemReader) error,
) (target T, _ error)

func BlockItemReadersDecodeItems

func BlockItemReadersDecodeItems[T any](
	itemf BlockItemReadersItemFunc,
	height base.Height,
	t base.BlockItemType,
	item func(uint64, uint64, T) error,
	f func(ir BlockItemReader) error,
) (count uint64, l []T, found bool, _ error)

func BlockItemReadersDecodeItemsFromReader

func BlockItemReadersDecodeItemsFromReader[T any](
	itemf BlockItemReadersFromReaderFunc,
	t base.BlockItemType,
	r io.Reader,
	compressFormat string,
	item func(uint64, uint64, T) error,
	f func(ir BlockItemReader) error,
) (count uint64, l []T, _ error)

func BlockItemReadersItemFuncWithRemote

func BlockItemReadersItemFuncWithRemote(
	readers *BlockItemReaders,
	fromRemotes RemotesBlockItemReadFunc,
	callback func(itemfile base.BlockItemFile, ir BlockItemReader, callback BlockItemReaderCallbackFunc) error,
) func(context.Context) BlockItemReadersItemFunc

func ConcurrentRequestProposal

func ConcurrentRequestProposal(
	ctx context.Context,
	point base.Point,
	proposer base.Node,
	previousBlock util.Hash,
	client NetworkClient,
	cis []quicstream.ConnInfo,
	networkID base.NetworkID,
) (base.ProposalSignFact, bool, error)

func ErrCallbackWorkerWithSyncSourcePool

func ErrCallbackWorkerWithSyncSourcePool(
	ctx context.Context,
	pool *SyncSourcePool,
	picksize int,
	semsize int64,
	errf func(error),
	f func(ctx context.Context, i, jobid uint64, nci NodeConnInfo) error,
) error

func FilterCandidates

func FilterCandidates(
	height base.Height, candidates []base.SuffrageCandidateStateValue,
) []base.SuffrageCandidateStateValue

func GetSuffrageFromDatabase

func GetSuffrageFromDatabase(
	db Database,
	height base.Height,
) (base.Suffrage, bool, error)

func InCandidates

func InCandidates(node base.Node, candidates []base.SuffrageCandidateStateValue) bool

func IsInLocalBlockItemFile

func IsInLocalBlockItemFile(uri url.URL) bool

func IsNewBallot

func IsNewBallot(last LastPoint, point base.StagePoint, isSuffrageConfirm bool) bool

func IsNewVoteproof

func IsNewVoteproof(last LastPoint, vp base.Voteproof) bool

func IsNewVoteproofbyPoint

func IsNewVoteproofbyPoint(
	last LastPoint,
	point base.StagePoint,
	isMajority, isSuffrageConfirm bool,
) bool

func IsNodeAddressInLastConsensusNodes

func IsNodeAddressInLastConsensusNodes(
	node base.Address, proof base.SuffrageProof, candidatesst base.State,
) (base.Suffrage, bool, error)

func IsNodeInLastConsensusNodes

func IsNodeInLastConsensusNodes(
	node base.Node, proof base.SuffrageProof, candidatesst base.State,
) (base.Suffrage, bool, error)

func IsSuffrageConfirmBallotFact

func IsSuffrageConfirmBallotFact(fact base.Fact) bool

func IsValidExpelWithSuffrage

func IsValidExpelWithSuffrage(
	height base.Height,
	expel base.SuffrageExpelOperation,
	suf base.Suffrage,
) error

func IsValidExpelWithSuffrageLifespan

func IsValidExpelWithSuffrageLifespan(
	height base.Height,
	expel base.SuffrageExpelOperation,
	suf base.Suffrage,
	lifespan base.Height,
) error

IsValidExpelWithSuffrageLifespan checks expel operation itself with suffrage and lifespan.

func IsValidVoteproofWithSuffrage

func IsValidVoteproofWithSuffrage(vp base.Voteproof, suf base.Suffrage) error

func JobWorkerWithSyncSourcePool

func JobWorkerWithSyncSourcePool(
	ctx context.Context,
	pool *SyncSourcePool,
	picksize int,
	semsize int64,
	f func(ctx context.Context, i, jobid uint64, nci NodeConnInfo) error,
) error

func LastCandidatesFromState

func LastCandidatesFromState(
	height base.Height, getStateFunc base.GetStateFunc,
) (base.Height, []base.SuffrageCandidateStateValue, error)

func LoadBlockItemFileBaseHeader

func LoadBlockItemFileBaseHeader(f io.Reader) (
	_ *bufio.Reader,
	writer, enc hint.Hint,
	_ error,
)

func LoadBlockItemFileHeader

func LoadBlockItemFileHeader(f io.Reader, v interface{}) (br *bufio.Reader, _ error)

func LoadBlockItemFilesPath

func LoadBlockItemFilesPath(
	root string,
	height base.Height,
	jsonenc encoder.Encoder,
) (bfiles base.BlockItemFiles, found bool, _ error)

func NewCandidatesOfMajoritySuffrageCandidateLimiterRule

func NewCandidatesOfMajoritySuffrageCandidateLimiterRule(
	ratio float64,
	getSuffrage func() (uint64, error),
) (uint64, error)

NewCandidatesOfMajoritySuffrageCandidateLimiterRule find the number of new candidates to prevent the current suffrage majority.

func NewMajoritySuffrageCandidateLimiter

func NewMajoritySuffrageCandidateLimiter(
	rule MajoritySuffrageCandidateLimiterRule,
	getSuffrage func() (uint64, error),
) base.SuffrageCandidateLimiter

func NewNode

func NewNode(pub base.Publickey, addr base.Address) base.BaseNode

func NewSuffrageFromState

func NewSuffrageFromState(st base.State) (suf base.Suffrage, _ error)

func NewSuffrageWithExpels

func NewSuffrageWithExpels(
	suf base.Suffrage,
	threshold base.Threshold,
	expels []base.SuffrageExpelOperation,
) (base.Suffrage, error)

func ReadBlockItemFileHeader

func ReadBlockItemFileHeader(f io.Reader) (br *bufio.Reader, _ []byte, _ error)

Types

type ACCEPTBallot

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

func NewACCEPTBallot

func NewACCEPTBallot(
	ivp base.INITVoteproof,
	signfact ACCEPTBallotSignFact,
	expels []base.SuffrageExpelOperation,
) ACCEPTBallot

func (ACCEPTBallot) BallotSignFact

func (bl ACCEPTBallot) BallotSignFact() base.ACCEPTBallotSignFact

func (*ACCEPTBallot) DecodeJSON

func (bl *ACCEPTBallot) DecodeJSON(b []byte, enc encoder.Encoder) error

func (ACCEPTBallot) Expels

func (bl ACCEPTBallot) Expels() []base.SuffrageExpelOperation

func (ACCEPTBallot) HashBytes

func (bl ACCEPTBallot) HashBytes() []byte

func (ACCEPTBallot) IsValid

func (bl ACCEPTBallot) IsValid(networkID []byte) error

func (ACCEPTBallot) MarshalJSON

func (bl ACCEPTBallot) MarshalJSON() ([]byte, error)

func (ACCEPTBallot) Point

func (bl ACCEPTBallot) Point() base.StagePoint

func (ACCEPTBallot) SignFact

func (bl ACCEPTBallot) SignFact() base.BallotSignFact

func (ACCEPTBallot) Voteproof

func (bl ACCEPTBallot) Voteproof() base.Voteproof

type ACCEPTBallotFact

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

func NewACCEPTBallotFact

func NewACCEPTBallotFact(
	point base.Point,
	proposal, newBlock util.Hash,
	expelfacts []util.Hash,
) ACCEPTBallotFact

func (*ACCEPTBallotFact) DecodeJSON

func (fact *ACCEPTBallotFact) DecodeJSON(b []byte, enc encoder.Encoder) error

func (ACCEPTBallotFact) ExpelFacts

func (fact ACCEPTBallotFact) ExpelFacts() []util.Hash

func (ACCEPTBallotFact) IsValid

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

func (ACCEPTBallotFact) MarshalJSON

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

func (ACCEPTBallotFact) NewBlock

func (fact ACCEPTBallotFact) NewBlock() util.Hash

func (ACCEPTBallotFact) Point

func (fact ACCEPTBallotFact) Point() base.StagePoint

func (ACCEPTBallotFact) Proposal

func (fact ACCEPTBallotFact) Proposal() util.Hash

func (ACCEPTBallotFact) Stage

func (fact ACCEPTBallotFact) Stage() base.Stage

type ACCEPTBallotFactJSONMarshaler

type ACCEPTBallotFactJSONMarshaler struct {
	Proposal util.Hash `json:"proposal"`
	NewBlock util.Hash `json:"new_block"`
	// contains filtered or unexported fields
}

type ACCEPTBallotFactJSONUnmarshaler

type ACCEPTBallotFactJSONUnmarshaler struct {
	Proposal valuehash.HashDecoder `json:"proposal"`
	NewBlock valuehash.HashDecoder `json:"new_block"`
	// contains filtered or unexported fields
}

type ACCEPTBallotSignFact

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

func NewACCEPTBallotSignFact

func NewACCEPTBallotSignFact(fact base.ACCEPTBallotFact) ACCEPTBallotSignFact

func (ACCEPTBallotSignFact) BallotFact

func (sf ACCEPTBallotSignFact) BallotFact() base.ACCEPTBallotFact

func (*ACCEPTBallotSignFact) DecodeJSON

func (sf *ACCEPTBallotSignFact) DecodeJSON(b []byte, enc encoder.Encoder) error

func (ACCEPTBallotSignFact) Fact

func (sf ACCEPTBallotSignFact) Fact() base.Fact

func (ACCEPTBallotSignFact) HashBytes

func (sf ACCEPTBallotSignFact) HashBytes() []byte

func (ACCEPTBallotSignFact) IsValid

func (sf ACCEPTBallotSignFact) IsValid(networkID []byte) error

func (ACCEPTBallotSignFact) MarshalJSON

func (sf ACCEPTBallotSignFact) MarshalJSON() ([]byte, error)

func (ACCEPTBallotSignFact) Node

func (sf ACCEPTBallotSignFact) Node() base.Address

func (*ACCEPTBallotSignFact) NodeSign

func (sf *ACCEPTBallotSignFact) NodeSign(priv base.Privatekey, networkID base.NetworkID, node base.Address) error

func (ACCEPTBallotSignFact) NodeSigns

func (sf ACCEPTBallotSignFact) NodeSigns() []base.NodeSign

func (ACCEPTBallotSignFact) Signer

func (sf ACCEPTBallotSignFact) Signer() base.Publickey

func (ACCEPTBallotSignFact) Signs

func (sf ACCEPTBallotSignFact) Signs() []base.Sign

type ACCEPTExpelVoteproof

type ACCEPTExpelVoteproof struct {
	ACCEPTVoteproof
	// contains filtered or unexported fields
}

func NewACCEPTExpelVoteproof

func NewACCEPTExpelVoteproof(point base.Point) ACCEPTExpelVoteproof

func (*ACCEPTExpelVoteproof) DecodeJSON

func (vp *ACCEPTExpelVoteproof) DecodeJSON(b []byte, enc encoder.Encoder) error

func (ACCEPTExpelVoteproof) Expels

func (vp ACCEPTExpelVoteproof) Expels() []base.SuffrageExpelOperation

func (*ACCEPTExpelVoteproof) Finish

func (vp *ACCEPTExpelVoteproof) Finish() baseVoteproof

func (ACCEPTExpelVoteproof) FinishedAt

func (vp ACCEPTExpelVoteproof) FinishedAt() time.Time

func (ACCEPTExpelVoteproof) HashBytes

func (vp ACCEPTExpelVoteproof) HashBytes() []byte

func (ACCEPTExpelVoteproof) ID

func (vp ACCEPTExpelVoteproof) ID() string

func (ACCEPTExpelVoteproof) IsExpelVoteproof

func (ACCEPTExpelVoteproof) IsExpelVoteproof() bool

func (ACCEPTExpelVoteproof) IsValid

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

func (ACCEPTExpelVoteproof) Majority

func (vp ACCEPTExpelVoteproof) Majority() base.BallotFact

func (ACCEPTExpelVoteproof) MarshalJSON

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

func (ACCEPTExpelVoteproof) Point

func (vp ACCEPTExpelVoteproof) Point() base.StagePoint

func (ACCEPTExpelVoteproof) Result

func (vp ACCEPTExpelVoteproof) Result() base.VoteResult

func (*ACCEPTExpelVoteproof) SetExpels

func (vp *ACCEPTExpelVoteproof) SetExpels(expels []base.SuffrageExpelOperation) *baseExpelVoteproof

func (*ACCEPTExpelVoteproof) SetMajority

func (vp *ACCEPTExpelVoteproof) SetMajority(fact base.BallotFact) *baseVoteproof

func (*ACCEPTExpelVoteproof) SetPoint

func (vp *ACCEPTExpelVoteproof) SetPoint(p base.StagePoint) *baseVoteproof

func (*ACCEPTExpelVoteproof) SetSignFacts

func (vp *ACCEPTExpelVoteproof) SetSignFacts(sfs []base.BallotSignFact) *baseVoteproof

func (*ACCEPTExpelVoteproof) SetThreshold

func (vp *ACCEPTExpelVoteproof) SetThreshold(s base.Threshold) *baseVoteproof

func (ACCEPTExpelVoteproof) SignFacts

func (vp ACCEPTExpelVoteproof) SignFacts() []base.BallotSignFact

func (ACCEPTExpelVoteproof) Threshold

func (vp ACCEPTExpelVoteproof) Threshold() base.Threshold

type ACCEPTStuckVoteproof

type ACCEPTStuckVoteproof struct {
	ACCEPTVoteproof
	// contains filtered or unexported fields
}

func NewACCEPTStuckVoteproof

func NewACCEPTStuckVoteproof(point base.Point) ACCEPTStuckVoteproof

func (*ACCEPTStuckVoteproof) DecodeJSON

func (vp *ACCEPTStuckVoteproof) DecodeJSON(b []byte, enc encoder.Encoder) error

func (*ACCEPTStuckVoteproof) Finish

func (ACCEPTStuckVoteproof) FinishedAt

func (vp ACCEPTStuckVoteproof) FinishedAt() time.Time

func (ACCEPTStuckVoteproof) HashBytes

func (vp ACCEPTStuckVoteproof) HashBytes() []byte

func (ACCEPTStuckVoteproof) ID

func (vp ACCEPTStuckVoteproof) ID() string

func (ACCEPTStuckVoteproof) IsStuckVoteproof

func (ACCEPTStuckVoteproof) IsStuckVoteproof() bool

func (ACCEPTStuckVoteproof) IsValid

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

func (ACCEPTStuckVoteproof) Majority

func (vp ACCEPTStuckVoteproof) Majority() base.BallotFact

func (ACCEPTStuckVoteproof) MarshalJSON

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

func (ACCEPTStuckVoteproof) Point

func (vp ACCEPTStuckVoteproof) Point() base.StagePoint

func (ACCEPTStuckVoteproof) Result

func (vp ACCEPTStuckVoteproof) Result() base.VoteResult

func (*ACCEPTStuckVoteproof) SetMajority

func (vp *ACCEPTStuckVoteproof) SetMajority(fact base.BallotFact) *baseVoteproof

func (*ACCEPTStuckVoteproof) SetPoint

func (vp *ACCEPTStuckVoteproof) SetPoint(p base.StagePoint) *baseVoteproof

func (*ACCEPTStuckVoteproof) SetSignFacts

func (vp *ACCEPTStuckVoteproof) SetSignFacts(sfs []base.BallotSignFact) *baseVoteproof

func (*ACCEPTStuckVoteproof) SetThreshold

func (vp *ACCEPTStuckVoteproof) SetThreshold(s base.Threshold) *baseVoteproof

func (ACCEPTStuckVoteproof) SignFacts

func (vp ACCEPTStuckVoteproof) SignFacts() []base.BallotSignFact

func (ACCEPTStuckVoteproof) Threshold

func (vp ACCEPTStuckVoteproof) Threshold() base.Threshold

type ACCEPTVoteproof

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

func NewACCEPTVoteproof

func NewACCEPTVoteproof(point base.Point) ACCEPTVoteproof

func (ACCEPTVoteproof) BallotMajority

func (vp ACCEPTVoteproof) BallotMajority() base.ACCEPTBallotFact

func (ACCEPTVoteproof) BallotSignFacts

func (vp ACCEPTVoteproof) BallotSignFacts() []base.ACCEPTBallotSignFact

func (*ACCEPTVoteproof) DecodeJSON

func (vp *ACCEPTVoteproof) DecodeJSON(b []byte, enc encoder.Encoder) error

func (*ACCEPTVoteproof) Finish

func (vp *ACCEPTVoteproof) Finish() baseVoteproof

func (ACCEPTVoteproof) FinishedAt

func (vp ACCEPTVoteproof) FinishedAt() time.Time

func (ACCEPTVoteproof) HashBytes

func (vp ACCEPTVoteproof) HashBytes() []byte

func (ACCEPTVoteproof) ID

func (vp ACCEPTVoteproof) ID() string

func (ACCEPTVoteproof) IsValid

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

func (ACCEPTVoteproof) Majority

func (vp ACCEPTVoteproof) Majority() base.BallotFact

func (ACCEPTVoteproof) MarshalJSON

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

func (ACCEPTVoteproof) Point

func (vp ACCEPTVoteproof) Point() base.StagePoint

func (ACCEPTVoteproof) Result

func (vp ACCEPTVoteproof) Result() base.VoteResult

func (*ACCEPTVoteproof) SetMajority

func (vp *ACCEPTVoteproof) SetMajority(fact base.BallotFact) *baseVoteproof

func (*ACCEPTVoteproof) SetPoint

func (vp *ACCEPTVoteproof) SetPoint(p base.StagePoint) *baseVoteproof

func (*ACCEPTVoteproof) SetSignFacts

func (vp *ACCEPTVoteproof) SetSignFacts(sfs []base.BallotSignFact) *baseVoteproof

func (*ACCEPTVoteproof) SetThreshold

func (vp *ACCEPTVoteproof) SetThreshold(s base.Threshold) *baseVoteproof

func (ACCEPTVoteproof) SignFacts

func (vp ACCEPTVoteproof) SignFacts() []base.BallotSignFact

func (ACCEPTVoteproof) Threshold

func (vp ACCEPTVoteproof) Threshold() base.Threshold

type BallotPool

type BallotPool interface {
	Ballot(_ base.Point, _ base.Stage, isSuffrageConfirm bool) (base.Ballot, bool, error)
	SetBallot(base.Ballot) (bool, error)
}

BallotPool stores latest ballots of local

type BaseDatabase

type BaseDatabase interface {
	State(key string) (base.State, bool, error)
	StateBytes(key string) (string, []byte, []byte, bool, error)
	ExistsInStateOperation(operationFactHash util.Hash) (bool, error)
	ExistsKnownOperation(operationHash util.Hash) (bool, error)
}

type BaseProposalSelector

type BaseProposalSelector struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewBaseProposalSelector

func NewBaseProposalSelector(
	local base.LocalNode,
	args *BaseProposalSelectorArgs,
) *BaseProposalSelector

func (*BaseProposalSelector) Select

func (p *BaseProposalSelector) Select(
	ctx context.Context,
	point base.Point,
	previousBlock util.Hash,
	wait time.Duration,
) (base.ProposalSignFact, error)

type BaseProposalSelectorArgs

type BaseProposalSelectorArgs struct {
	Pool                    ProposalPool
	ProposerSelectFunc      ProposerSelectFunc
	Maker                   *ProposalMaker
	GetNodesFunc            func(base.Height) ([]base.Node, bool, error)
	RequestFunc             func(context.Context, base.Point, base.Node, util.Hash) (base.ProposalSignFact, bool, error)
	TimeoutRequest          func() time.Duration
	RequestProposalInterval time.Duration
	MinProposerWait         time.Duration
}

func NewBaseProposalSelectorArgs

func NewBaseProposalSelectorArgs() *BaseProposalSelectorArgs

type BlockBasedProposerSelector

type BlockBasedProposerSelector struct{}

func NewBlockBasedProposerSelector

func NewBlockBasedProposerSelector() BlockBasedProposerSelector

func (BlockBasedProposerSelector) Select

func (BlockBasedProposerSelector) Select(
	_ context.Context, point base.Point, nodes []base.Node, previousBlock util.Hash,
) (base.Node, error)

type BlockImporter

type BlockImporter interface {
	WriteMap(base.BlockMap) error
	WriteItem(base.BlockItemType, BlockItemReader) error
	Save(context.Context) (func(context.Context) error, error)
	CancelImport(context.Context) error
}

type BlockItemFile

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

func NewBlockItemFile

func NewBlockItemFile(uri url.URL, compressFormat string) BlockItemFile

func NewFileBlockItemFile

func NewFileBlockItemFile(f string, compressFormat string) BlockItemFile

func NewLocalFSBlockItemFile

func NewLocalFSBlockItemFile(f string, compressFormat string) BlockItemFile

func (BlockItemFile) CompressFormat

func (f BlockItemFile) CompressFormat() string

func (BlockItemFile) IsValid

func (f BlockItemFile) IsValid([]byte) error

func (BlockItemFile) MarshalJSON

func (f BlockItemFile) MarshalJSON() ([]byte, error)

func (BlockItemFile) URI

func (f BlockItemFile) URI() url.URL

func (*BlockItemFile) UnmarshalJSON

func (f *BlockItemFile) UnmarshalJSON(b []byte) error

type BlockItemFileBaseItemsHeader

type BlockItemFileBaseItemsHeader struct {
	Writer  hint.Hint `json:"writer"`
	Encoder hint.Hint `json:"encoder"`
}

type BlockItemFileJSONMarshaler

type BlockItemFileJSONMarshaler struct {
	URI            string `json:"uri,omitempty"`
	CompressFormat string `json:"compress_format,omitempty"`
	hint.BaseHinter
}

type BlockItemFiles

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

func NewBlockItemFiles

func NewBlockItemFiles(items map[base.BlockItemType]base.BlockItemFile) BlockItemFiles

func (*BlockItemFiles) DecodeJSON

func (f *BlockItemFiles) DecodeJSON(b []byte, enc encoder.Encoder) error

func (BlockItemFiles) IsValid

func (f BlockItemFiles) IsValid([]byte) error

func (BlockItemFiles) Item

func (BlockItemFiles) Items

func (BlockItemFiles) MarshalJSON

func (f BlockItemFiles) MarshalJSON() ([]byte, error)

type BlockItemFilesJSONMarshaler

type BlockItemFilesJSONMarshaler struct {
	Items map[base.BlockItemType]base.BlockItemFile `json:"items"`
	hint.BaseHinter
}

type BlockItemFilesJSONUnmarshaler

type BlockItemFilesJSONUnmarshaler struct {
	Items map[base.BlockItemType]json.RawMessage `json:"items"`
	hint.BaseHinter
}

type BlockItemFilesMaker

type BlockItemFilesMaker struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewBlockItemFilesMaker

func NewBlockItemFilesMaker(jsonenc encoder.Encoder) *BlockItemFilesMaker

func (*BlockItemFilesMaker) Bytes

func (f *BlockItemFilesMaker) Bytes() ([]byte, error)

func (*BlockItemFilesMaker) Files

func (*BlockItemFilesMaker) Save

func (f *BlockItemFilesMaker) Save(s string) error

func (*BlockItemFilesMaker) SetItem

type BlockItemReader

type BlockItemReader interface {
	Type() base.BlockItemType
	Encoder() encoder.Encoder
	Reader() *util.CompressedReader
	Decode() (interface{}, error)
	DecodeItems(func(total uint64, index uint64, _ interface{}) error) (count uint64, _ error)
}

type BlockItemReaderCallbackFunc

type BlockItemReaderCallbackFunc func(BlockItemReader) error

type BlockItemReaders

type BlockItemReaders struct {
	*hint.CompatibleSet[NewBlockItemReaderFunc]

	*util.ContextDaemon
	*logging.Logging
	// contains filtered or unexported fields
}

func NewBlockItemReaders

func NewBlockItemReaders(
	root string,
	encs *encoder.Encoders,
	args *BlockItemReadersArgs,
) *BlockItemReaders

func (*BlockItemReaders) Add

func (rs *BlockItemReaders) Add(writerhint hint.Hint, v NewBlockItemReaderFunc) error

func (*BlockItemReaders) Close

func (rs *BlockItemReaders) Close()

func (*BlockItemReaders) Item

func (*BlockItemReaders) ItemFile

func (*BlockItemReaders) ItemFiles

func (rs *BlockItemReaders) ItemFiles(height base.Height) (base.BlockItemFiles, bool, error)

func (*BlockItemReaders) ItemFilesReader

func (rs *BlockItemReaders) ItemFilesReader(
	height base.Height,
	f func(io.Reader) error,
) (bool, error)

func (*BlockItemReaders) ItemFromReader

func (rs *BlockItemReaders) ItemFromReader(
	t base.BlockItemType,
	r io.Reader,
	compressFormat string,
	callback BlockItemReaderCallbackFunc,
) error

func (*BlockItemReaders) ReadFileFromItemFile

func (rs *BlockItemReaders) ReadFileFromItemFile(height base.Height, bfile base.BlockItemFile) (*os.File, bool, error)

func (*BlockItemReaders) Reader

func (rs *BlockItemReaders) Reader(
	height base.Height,
	t base.BlockItemType,
	callback func(_ io.Reader, compressFormat string) error,
) (bool, error)

func (*BlockItemReaders) Root

func (rs *BlockItemReaders) Root() string

func (*BlockItemReaders) WriteItemFiles

func (rs *BlockItemReaders) WriteItemFiles(height base.Height, b []byte) (updated bool, _ error)

type BlockItemReadersArgs

type BlockItemReadersArgs struct {
	DecompressReaderFunc            util.DecompressReaderFunc
	LoadEmptyHeightsFunc            func() ([]base.Height, error)
	AddEmptyHeightFunc              func(base.Height) error
	CancelAddedEmptyHeightFunc      func(base.Height) error
	RemoveEmptyAfter                func() time.Duration
	RemoveEmptyInterval             func() time.Duration
	WhenBlockItemFilesUpdated       func(prev base.BlockItemFiles, updated base.BlockItemFiles)
	WhenEmptyHeightDirectoryRemoved func(base.Height)
}

func NewBlockItemReadersArgs

func NewBlockItemReadersArgs() *BlockItemReadersArgs

type BlockItemReadersFromReaderFunc

type BlockItemReadersFromReaderFunc func(
	_ base.BlockItemType,
	_ io.Reader,
	compressFormat string,
	_ BlockItemReaderCallbackFunc,
) error

type BlockReader

type BlockReader interface {
	BlockMap() (base.BlockMap, bool, error)
	BlockItemFiles() (base.BlockItemFiles, bool, error)
	Reader(base.BlockItemType) (io.ReadCloser, bool, error)
	ChecksumReader(base.BlockItemType) (util.ChecksumReader, bool, error)
	Item(base.BlockItemType) (interface{}, bool, error)
	Items(func(base.BlockMapItem, interface{}, bool, error) bool) error
}

type BlockWriteDatabase

type BlockWriteDatabase interface {
	Close() error
	Cancel() error
	BlockMap() (base.BlockMap, error)
	SetBlockMap(base.BlockMap) error
	SetStates(sts []base.State) error
	SetOperations(ops []util.Hash) error // NOTE operation hash, not operation fact hash
	SetSuffrageProof(base.SuffrageProof) error
	SuffrageState() base.State
	NetworkPolicy() base.NetworkPolicy
	Write() error
	TempDatabase() (TempDatabase, error)
}

type BlockWriter

type BlockWriter interface {
	SetOperationsSize(uint64)
	SetProcessResult(
		_ context.Context,
		index uint64,
		ophash, facthash util.Hash,
		instate bool,
		errorreason base.OperationProcessReasonError,
	) error
	SetStates(_ context.Context, index uint64, values []base.StateMergeValue, operation base.Operation) error
	Manifest(_ context.Context, previous base.Manifest) (base.Manifest, error)
	SetINITVoteproof(context.Context, base.INITVoteproof) error
	SetACCEPTVoteproof(context.Context, base.ACCEPTVoteproof) error
	Save(context.Context) (base.BlockMap, error)
	Cancel() error
}

type Database

type Database interface {
	util.Daemon
	Close() error
	BlockMap(height base.Height) (base.BlockMap, bool, error)
	BlockMapBytes(base.Height) (string, []byte, []byte, bool, error)
	LastBlockMap() (base.BlockMap, bool, error)
	LastBlockMapBytes() (string, []byte, []byte, bool, error)
	LastSuffrageProof() (base.SuffrageProof, bool, error)
	LastSuffrageProofBytes() (string, []byte, []byte, bool, base.Height, error)
	SuffrageProof(suffrageHeight base.Height) (base.SuffrageProof, bool, error)
	SuffrageProofBytes(suffrageHeight base.Height) (string, []byte, []byte, bool, error)
	SuffrageProofByBlockHeight(blockheight base.Height) (base.SuffrageProof, bool, error)
	LastNetworkPolicy() base.NetworkPolicy
	State(key string) (base.State, bool, error)
	StateBytes(key string) (string, []byte, []byte, bool, error)
	// NOTE ExistsInStateOperation has only operation facts, which is in state
	ExistsInStateOperation(operationFactHash util.Hash) (bool, error)
	// NOTE ExistsKnownOperation has the known operation hashes
	ExistsKnownOperation(operationHash util.Hash) (bool, error)
	NewBlockWriteDatabase(height base.Height) (BlockWriteDatabase, error)
	MergeBlockWriteDatabase(BlockWriteDatabase) error
	MergeAllPermanent() error
	RemoveBlocks(base.Height) (bool, error)
}

Database serves some of block items like blockmap, states and operations from TempDatabases and PermanentDatabase. It has several TempDatabases and one PermanentDatabase.

type DefaultProposalProcessor

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

func NewDefaultProposalProcessor

func NewDefaultProposalProcessor(
	proposal base.ProposalSignFact,
	previous base.Manifest,
	args *DefaultProposalProcessorArgs,
) (*DefaultProposalProcessor, error)

func (*DefaultProposalProcessor) Cancel

func (p *DefaultProposalProcessor) Cancel() error

func (*DefaultProposalProcessor) Process

func (*DefaultProposalProcessor) Proposal

func (*DefaultProposalProcessor) Save

type DefaultProposalProcessorArgs

type DefaultProposalProcessorArgs struct {
	NewWriterFunc             NewBlockWriterFunc
	GetStateFunc              base.GetStateFunc
	GetOperationFunc          OperationProcessorGetOperationFunction
	NewOperationProcessorFunc NewOperationProcessorFunc
	EmptyProposalNoBlockFunc  func() bool
	MaxWorkerSize             int64
}

func NewDefaultProposalProcessorArgs

func NewDefaultProposalProcessorArgs() *DefaultProposalProcessorArgs

type EmptyOperationsACCEPTBallotFact

type EmptyOperationsACCEPTBallotFact struct {
	ACCEPTBallotFact
}

func NewEmptyOperationsACCEPTBallotFact

func NewEmptyOperationsACCEPTBallotFact(
	point base.Point,
	proposal util.Hash,
) EmptyOperationsACCEPTBallotFact

func (EmptyOperationsACCEPTBallotFact) ExpelFacts

func (fact EmptyOperationsACCEPTBallotFact) ExpelFacts() []util.Hash

func (EmptyOperationsACCEPTBallotFact) Point

func (fact EmptyOperationsACCEPTBallotFact) Point() base.StagePoint

func (EmptyOperationsACCEPTBallotFact) Stage

func (fact EmptyOperationsACCEPTBallotFact) Stage() base.Stage

type EmptyProposalINITBallotFact

type EmptyProposalINITBallotFact struct {
	INITBallotFact
	// contains filtered or unexported fields
}

func NewEmptyProposalINITBallotFact

func NewEmptyProposalINITBallotFact(
	point base.Point,
	previousBlock, proposal util.Hash,
) EmptyProposalINITBallotFact

func (*EmptyProposalINITBallotFact) DecodeJSON

func (fact *EmptyProposalINITBallotFact) DecodeJSON(b []byte, enc encoder.Encoder) error

func (EmptyProposalINITBallotFact) ExpelFacts

func (fact EmptyProposalINITBallotFact) ExpelFacts() []util.Hash

func (EmptyProposalINITBallotFact) IsValid

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

func (EmptyProposalINITBallotFact) MarshalJSON

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

func (EmptyProposalINITBallotFact) Point

func (fact EmptyProposalINITBallotFact) Point() base.StagePoint

func (EmptyProposalINITBallotFact) Stage

func (fact EmptyProposalINITBallotFact) Stage() base.Stage

type EmptyProposalINITBallotFactJSONMarshaler

type EmptyProposalINITBallotFactJSONMarshaler struct {
	R string `json:"r"`
	INITBallotFactJSONMarshaler
}

type ExpelBallotFact

type ExpelBallotFact interface {
	ExpelFacts() []util.Hash
}

type FixedSuffrageCandidateLimiterRule

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

func NewFixedSuffrageCandidateLimiterRule

func NewFixedSuffrageCandidateLimiterRule(limit uint64) FixedSuffrageCandidateLimiterRule

func (FixedSuffrageCandidateLimiterRule) HashBytes

func (l FixedSuffrageCandidateLimiterRule) HashBytes() []byte

func (FixedSuffrageCandidateLimiterRule) IsValid

func (FixedSuffrageCandidateLimiterRule) Limit

func (FixedSuffrageCandidateLimiterRule) MarshalJSON

func (l FixedSuffrageCandidateLimiterRule) MarshalJSON() ([]byte, error)

func (*FixedSuffrageCandidateLimiterRule) UnmarshalJSON

func (l *FixedSuffrageCandidateLimiterRule) UnmarshalJSON(b []byte) error

type FuncProposerSelector

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

func NewFixedProposerSelector

func NewFixedProposerSelector(
	selectfunc func(base.Point, []base.Node, util.Hash) (base.Node, error),
) FuncProposerSelector

func (FuncProposerSelector) Select

func (p FuncProposerSelector) Select(
	_ context.Context, point base.Point, nodes []base.Node, previousBlock util.Hash,
) (base.Node, error)

type GetLastSuffrageCandidateStateRemoteFunc

type GetLastSuffrageCandidateStateRemoteFunc func(context.Context) (base.State, bool, error)

type GetLastSuffrageProofFromRemoteFunc

type GetLastSuffrageProofFromRemoteFunc func(context.Context) (base.Height, base.SuffrageProof, bool, error)

type GetSuffrageByBlockHeight

type GetSuffrageByBlockHeight func(nextheight base.Height) (base.Suffrage, bool, error)

type GetSuffrageProofFromRemoteFunc

type GetSuffrageProofFromRemoteFunc func(_ context.Context, suffrageheight base.Height) (
	base.SuffrageProof, bool, error)

type INITBallot

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

func NewINITBallot

func NewINITBallot(
	vp base.Voteproof,
	signfact INITBallotSignFact,
	expels []base.SuffrageExpelOperation,
) INITBallot

func (INITBallot) BallotSignFact

func (bl INITBallot) BallotSignFact() base.INITBallotSignFact

func (*INITBallot) DecodeJSON

func (bl *INITBallot) DecodeJSON(b []byte, enc encoder.Encoder) error

func (INITBallot) Expels

func (bl INITBallot) Expels() []base.SuffrageExpelOperation

func (INITBallot) HashBytes

func (bl INITBallot) HashBytes() []byte

func (INITBallot) IsValid

func (bl INITBallot) IsValid(networkID []byte) error

func (INITBallot) MarshalJSON

func (bl INITBallot) MarshalJSON() ([]byte, error)

func (INITBallot) Point

func (bl INITBallot) Point() base.StagePoint

func (INITBallot) SignFact

func (bl INITBallot) SignFact() base.BallotSignFact

func (INITBallot) Voteproof

func (bl INITBallot) Voteproof() base.Voteproof

type INITBallotFact

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

func NewINITBallotFact

func NewINITBallotFact(
	point base.Point,
	previousBlock, proposal util.Hash,
	expelfacts []util.Hash,
) INITBallotFact

func (*INITBallotFact) DecodeJSON

func (fact *INITBallotFact) DecodeJSON(b []byte, enc encoder.Encoder) error

func (INITBallotFact) ExpelFacts

func (fact INITBallotFact) ExpelFacts() []util.Hash

func (INITBallotFact) IsValid

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

func (INITBallotFact) MarshalJSON

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

func (INITBallotFact) Point

func (fact INITBallotFact) Point() base.StagePoint

func (INITBallotFact) PreviousBlock

func (fact INITBallotFact) PreviousBlock() util.Hash

func (INITBallotFact) Proposal

func (fact INITBallotFact) Proposal() util.Hash

func (INITBallotFact) Stage

func (fact INITBallotFact) Stage() base.Stage

type INITBallotFactJSONMarshaler

type INITBallotFactJSONMarshaler struct {
	PreviousBlock util.Hash `json:"previous_block"`
	Proposal      util.Hash `json:"proposal"`
	// contains filtered or unexported fields
}

type INITBallotFactJSONUnmarshaler

type INITBallotFactJSONUnmarshaler struct {
	PreviousBlock valuehash.HashDecoder `json:"previous_block"`
	Proposal      valuehash.HashDecoder `json:"proposal"`
	// contains filtered or unexported fields
}

type INITBallotSignFact

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

func NewINITBallotSignFact

func NewINITBallotSignFact(fact base.INITBallotFact) INITBallotSignFact

func (INITBallotSignFact) BallotFact

func (sf INITBallotSignFact) BallotFact() base.INITBallotFact

func (*INITBallotSignFact) DecodeJSON

func (sf *INITBallotSignFact) DecodeJSON(b []byte, enc encoder.Encoder) error

func (INITBallotSignFact) Fact

func (sf INITBallotSignFact) Fact() base.Fact

func (INITBallotSignFact) HashBytes

func (sf INITBallotSignFact) HashBytes() []byte

func (INITBallotSignFact) IsValid

func (sf INITBallotSignFact) IsValid(networkID []byte) error

func (INITBallotSignFact) MarshalJSON

func (sf INITBallotSignFact) MarshalJSON() ([]byte, error)

func (INITBallotSignFact) Node

func (sf INITBallotSignFact) Node() base.Address

func (*INITBallotSignFact) NodeSign

func (sf *INITBallotSignFact) NodeSign(priv base.Privatekey, networkID base.NetworkID, node base.Address) error

func (INITBallotSignFact) NodeSigns

func (sf INITBallotSignFact) NodeSigns() []base.NodeSign

func (INITBallotSignFact) Signer

func (sf INITBallotSignFact) Signer() base.Publickey

func (INITBallotSignFact) Signs

func (sf INITBallotSignFact) Signs() []base.Sign

type INITExpelVoteproof

type INITExpelVoteproof struct {
	INITVoteproof
	// contains filtered or unexported fields
}

func NewINITExpelVoteproof

func NewINITExpelVoteproof(point base.Point) INITExpelVoteproof

func (*INITExpelVoteproof) DecodeJSON

func (vp *INITExpelVoteproof) DecodeJSON(b []byte, enc encoder.Encoder) error

func (INITExpelVoteproof) Expels

func (vp INITExpelVoteproof) Expels() []base.SuffrageExpelOperation

func (*INITExpelVoteproof) Finish

func (vp *INITExpelVoteproof) Finish() baseVoteproof

func (INITExpelVoteproof) FinishedAt

func (vp INITExpelVoteproof) FinishedAt() time.Time

func (INITExpelVoteproof) HashBytes

func (vp INITExpelVoteproof) HashBytes() []byte

func (INITExpelVoteproof) ID

func (vp INITExpelVoteproof) ID() string

func (INITExpelVoteproof) IsExpelVoteproof

func (INITExpelVoteproof) IsExpelVoteproof() bool

func (INITExpelVoteproof) IsValid

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

func (INITExpelVoteproof) Majority

func (vp INITExpelVoteproof) Majority() base.BallotFact

func (INITExpelVoteproof) MarshalJSON

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

func (INITExpelVoteproof) Point

func (vp INITExpelVoteproof) Point() base.StagePoint

func (INITExpelVoteproof) Result

func (vp INITExpelVoteproof) Result() base.VoteResult

func (*INITExpelVoteproof) SetExpels

func (vp *INITExpelVoteproof) SetExpels(expels []base.SuffrageExpelOperation) *baseExpelVoteproof

func (*INITExpelVoteproof) SetMajority

func (vp *INITExpelVoteproof) SetMajority(fact base.BallotFact) *baseVoteproof

func (*INITExpelVoteproof) SetPoint

func (vp *INITExpelVoteproof) SetPoint(p base.StagePoint) *baseVoteproof

func (*INITExpelVoteproof) SetSignFacts

func (vp *INITExpelVoteproof) SetSignFacts(sfs []base.BallotSignFact) *baseVoteproof

func (*INITExpelVoteproof) SetThreshold

func (vp *INITExpelVoteproof) SetThreshold(s base.Threshold) *baseVoteproof

func (INITExpelVoteproof) SignFacts

func (vp INITExpelVoteproof) SignFacts() []base.BallotSignFact

func (INITExpelVoteproof) Threshold

func (vp INITExpelVoteproof) Threshold() base.Threshold

type INITStuckVoteproof

type INITStuckVoteproof struct {
	INITVoteproof
	// contains filtered or unexported fields
}

func NewINITStuckVoteproof

func NewINITStuckVoteproof(point base.Point) INITStuckVoteproof

func (*INITStuckVoteproof) DecodeJSON

func (vp *INITStuckVoteproof) DecodeJSON(b []byte, enc encoder.Encoder) error

func (*INITStuckVoteproof) Finish

func (vp *INITStuckVoteproof) Finish() *INITStuckVoteproof

func (INITStuckVoteproof) FinishedAt

func (vp INITStuckVoteproof) FinishedAt() time.Time

func (INITStuckVoteproof) HashBytes

func (vp INITStuckVoteproof) HashBytes() []byte

func (INITStuckVoteproof) ID

func (vp INITStuckVoteproof) ID() string

func (INITStuckVoteproof) IsStuckVoteproof

func (INITStuckVoteproof) IsStuckVoteproof() bool

func (INITStuckVoteproof) IsValid

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

func (INITStuckVoteproof) Majority

func (vp INITStuckVoteproof) Majority() base.BallotFact

func (INITStuckVoteproof) MarshalJSON

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

func (INITStuckVoteproof) Point

func (vp INITStuckVoteproof) Point() base.StagePoint

func (INITStuckVoteproof) Result

func (vp INITStuckVoteproof) Result() base.VoteResult

func (*INITStuckVoteproof) SetMajority

func (vp *INITStuckVoteproof) SetMajority(fact base.BallotFact) *baseVoteproof

func (*INITStuckVoteproof) SetPoint

func (vp *INITStuckVoteproof) SetPoint(p base.StagePoint) *baseVoteproof

func (*INITStuckVoteproof) SetSignFacts

func (vp *INITStuckVoteproof) SetSignFacts(sfs []base.BallotSignFact) *baseVoteproof

func (*INITStuckVoteproof) SetThreshold

func (vp *INITStuckVoteproof) SetThreshold(s base.Threshold) *baseVoteproof

func (INITStuckVoteproof) SignFacts

func (vp INITStuckVoteproof) SignFacts() []base.BallotSignFact

func (INITStuckVoteproof) Threshold

func (vp INITStuckVoteproof) Threshold() base.Threshold

type INITVoteproof

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

func NewINITVoteproof

func NewINITVoteproof(point base.Point) INITVoteproof

func (INITVoteproof) BallotMajority

func (vp INITVoteproof) BallotMajority() base.INITBallotFact

func (INITVoteproof) BallotSignFacts

func (vp INITVoteproof) BallotSignFacts() []base.INITBallotSignFact

func (*INITVoteproof) DecodeJSON

func (vp *INITVoteproof) DecodeJSON(b []byte, enc encoder.Encoder) error

func (*INITVoteproof) Finish

func (vp *INITVoteproof) Finish() baseVoteproof

func (INITVoteproof) FinishedAt

func (vp INITVoteproof) FinishedAt() time.Time

func (INITVoteproof) HashBytes

func (vp INITVoteproof) HashBytes() []byte

func (INITVoteproof) ID

func (vp INITVoteproof) ID() string

func (INITVoteproof) IsValid

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

func (INITVoteproof) Majority

func (vp INITVoteproof) Majority() base.BallotFact

func (INITVoteproof) MarshalJSON

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

func (INITVoteproof) Point

func (vp INITVoteproof) Point() base.StagePoint

func (INITVoteproof) Result

func (vp INITVoteproof) Result() base.VoteResult

func (*INITVoteproof) SetMajority

func (vp *INITVoteproof) SetMajority(fact base.BallotFact) *baseVoteproof

func (*INITVoteproof) SetPoint

func (vp *INITVoteproof) SetPoint(p base.StagePoint) *baseVoteproof

func (*INITVoteproof) SetSignFacts

func (vp *INITVoteproof) SetSignFacts(sfs []base.BallotSignFact) *baseVoteproof

func (*INITVoteproof) SetThreshold

func (vp *INITVoteproof) SetThreshold(s base.Threshold) *baseVoteproof

func (INITVoteproof) SignFacts

func (vp INITVoteproof) SignFacts() []base.BallotSignFact

func (INITVoteproof) Threshold

func (vp INITVoteproof) Threshold() base.Threshold

type LastConsensusNodesWatcher

type LastConsensusNodesWatcher struct {
	*util.ContextDaemon
	*logging.Logging
	// contains filtered or unexported fields
}

func NewLastConsensusNodesWatcher

func NewLastConsensusNodesWatcher(
	getFromLocal func() (base.Height, base.SuffrageProof, base.State, bool, error),
	getFromRemote func(context.Context, base.State) (base.Height, []base.SuffrageProof, base.State, error),
	whenUpdatedf func(context.Context, base.SuffrageProof, base.SuffrageProof, base.State),
	checkInterval time.Duration,
) (*LastConsensusNodesWatcher, error)

func (*LastConsensusNodesWatcher) Exists

func (*LastConsensusNodesWatcher) GetSuffrage

func (u *LastConsensusNodesWatcher) GetSuffrage(height base.Height) (base.Suffrage, bool, error)

func (*LastConsensusNodesWatcher) Last

func (*LastConsensusNodesWatcher) SetWhenUpdated

func (u *LastConsensusNodesWatcher) SetWhenUpdated(
	whenUpdated func(context.Context, base.SuffrageProof, base.SuffrageProof, base.State),
)

type LastPoint

type LastPoint struct {
	base.StagePoint
	// contains filtered or unexported fields
}

func NewLastPoint

func NewLastPoint(
	point base.StagePoint,
	isMajority, isSuffrageConfirm bool,
) (LastPoint, error)

func NewLastPointFromVoteproof

func NewLastPointFromVoteproof(vp base.Voteproof) (LastPoint, error)

func (LastPoint) Before

func (l LastPoint) Before(
	point base.StagePoint,
	isSuffrageConfirm bool,
) bool

func (LastPoint) IsMajority

func (l LastPoint) IsMajority() bool

func (LastPoint) IsSuffrageConfirm

func (l LastPoint) IsSuffrageConfirm() bool

type LastVoteproofs

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

func (LastVoteproofs) ACCEPT

func (l LastVoteproofs) ACCEPT() base.ACCEPTVoteproof

func (LastVoteproofs) Cap

func (l LastVoteproofs) Cap() base.Voteproof

func (LastVoteproofs) INIT

func (LastVoteproofs) IsNew

func (l LastVoteproofs) IsNew(vp base.Voteproof) bool

func (LastVoteproofs) Majority

func (l LastVoteproofs) Majority() base.Voteproof

func (LastVoteproofs) PreviousBlockForNextRound

func (l LastVoteproofs) PreviousBlockForNextRound(vp base.Voteproof) util.Hash

PreviousBlockForNextRound finds the previous block hash from last majority voteproof.

-------------------------------------- | m | v | | heights | -------------------------------------- | init | init | X | | | accept | init | O | m == v - 1 | | init | accept | O | m == v | | accept | accept | O | m == v - 1 | --------------------------------------

* 'm' is last majority voteproof * 'v' is draw voteproof, new incoming voteproof for next round

type LastVoteproofsHandler

type LastVoteproofsHandler struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewLastVoteproofsHandler

func NewLastVoteproofsHandler() *LastVoteproofsHandler

func (*LastVoteproofsHandler) ForceSetLast

func (l *LastVoteproofsHandler) ForceSetLast(vp base.Voteproof) bool

func (*LastVoteproofsHandler) IsNew

func (*LastVoteproofsHandler) Last

func (*LastVoteproofsHandler) Set

func (*LastVoteproofsHandler) Voteproofs

func (l *LastVoteproofsHandler) Voteproofs(point base.StagePoint) (LastVoteproofs, bool)

type LocalNode

type LocalNode struct {
	base.BaseLocalNode
}

func NewLocalNode

func NewLocalNode(priv base.Privatekey, addr base.Address) LocalNode

type MajoritySuffrageCandidateLimiterRule

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

func NewMajoritySuffrageCandidateLimiterRule

func NewMajoritySuffrageCandidateLimiterRule(ratio float64, min, max uint64) MajoritySuffrageCandidateLimiterRule

func (MajoritySuffrageCandidateLimiterRule) HashBytes

func (MajoritySuffrageCandidateLimiterRule) IsValid

func (MajoritySuffrageCandidateLimiterRule) MarshalJSON

func (l MajoritySuffrageCandidateLimiterRule) MarshalJSON() ([]byte, error)

func (MajoritySuffrageCandidateLimiterRule) Max

func (MajoritySuffrageCandidateLimiterRule) Min

func (MajoritySuffrageCandidateLimiterRule) Ratio

func (*MajoritySuffrageCandidateLimiterRule) UnmarshalJSON

func (l *MajoritySuffrageCandidateLimiterRule) UnmarshalJSON(b []byte) error

type Manifest

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

func NewManifest

func NewManifest(
	height base.Height,
	previous,
	proposal,
	operationsTree,
	statesTree,
	suffrage util.Hash,
	proposedAt time.Time,
) Manifest

func (Manifest) Hash

func (m Manifest) Hash() util.Hash

func (Manifest) Height

func (m Manifest) Height() base.Height

func (Manifest) IsValid

func (m Manifest) IsValid([]byte) error

func (Manifest) MarshalJSON

func (m Manifest) MarshalJSON() ([]byte, error)

func (Manifest) OperationsTree

func (m Manifest) OperationsTree() util.Hash

func (Manifest) Previous

func (m Manifest) Previous() util.Hash

func (Manifest) Proposal

func (m Manifest) Proposal() util.Hash

func (Manifest) ProposedAt

func (m Manifest) ProposedAt() time.Time

func (Manifest) StatesTree

func (m Manifest) StatesTree() util.Hash

func (Manifest) Suffrage

func (m Manifest) Suffrage() util.Hash

func (*Manifest) UnmarshalJSON

func (m *Manifest) UnmarshalJSON(b []byte) error

type ManifestJSONMarshaler

type ManifestJSONMarshaler struct {
	ProposedAt     time.Time `json:"proposed_at"`
	StatesTree     util.Hash `json:"states_tree"`
	Hash           util.Hash `json:"hash"`
	Previous       util.Hash `json:"previous"`
	Proposal       util.Hash `json:"proposal"`
	OperationsTree util.Hash `json:"operations_tree"`
	Suffrage       util.Hash `json:"suffrage"`
	hint.BaseHinter
	Height base.Height `json:"height"`
}

type ManifestJSONUnmarshaler

type ManifestJSONUnmarshaler struct {
	ProposedAt     localtime.Time        `json:"proposed_at"`
	Hash           valuehash.HashDecoder `json:"hash"`
	Previous       valuehash.HashDecoder `json:"previous"`
	Proposal       valuehash.HashDecoder `json:"proposal"`
	OperationsTree valuehash.HashDecoder `json:"operations_tree"`
	StatesTree     valuehash.HashDecoder `json:"states_tree"`
	Suffrage       valuehash.HashDecoder `json:"suffrage"`
	Height         base.HeightDecoder    `json:"height"`
}

type NetworkClient

type NetworkClient interface {
	// revive:disable:line-length-limit
	Operation(_ context.Context, _ quicstream.ConnInfo, operationhash util.Hash) (base.Operation, bool, error)
	SendOperation(context.Context, quicstream.ConnInfo, base.Operation) (bool, error)
	RequestProposal(_ context.Context, connInfo quicstream.ConnInfo, point base.Point, proposer base.Address, previousBlock util.Hash) (base.ProposalSignFact, bool, error)
	Proposal(_ context.Context, connInfo quicstream.ConnInfo, facthash util.Hash) (base.ProposalSignFact, bool, error)
	LastSuffrageProof(_ context.Context, connInfo quicstream.ConnInfo, state util.Hash) (lastheight base.Height, _ base.SuffrageProof, updated bool, _ error)
	SuffrageProof(_ context.Context, connInfo quicstream.ConnInfo, suffrageheight base.Height) (_ base.SuffrageProof, found bool, _ error)
	LastBlockMap(_ context.Context, _ quicstream.ConnInfo, manifest util.Hash) (_ base.BlockMap, updated bool, _ error)
	BlockMap(context.Context, quicstream.ConnInfo, base.Height) (_ base.BlockMap, updated bool, _ error)
	BlockItem(context.Context, quicstream.ConnInfo, base.Height, base.BlockItemType, func(_ io.Reader, uri url.URL, compressFormat string) error) (bool, error)
	BlockItemFiles(context.Context, quicstream.ConnInfo, base.Height, base.Privatekey, base.NetworkID, func(_ io.Reader) error) (found bool, _ error)
	NodeChallenge(_ context.Context, _ quicstream.ConnInfo, _ base.NetworkID, _ base.Address, _ base.Publickey, input []byte, me base.LocalNode) (base.Signature, error)
	SuffrageNodeConnInfo(context.Context, quicstream.ConnInfo) ([]NodeConnInfo, error)
	SyncSourceConnInfo(context.Context, quicstream.ConnInfo) ([]NodeConnInfo, error)
	State(_ context.Context, _ quicstream.ConnInfo, key string, _ util.Hash) (base.State, bool, error)
	ExistsInStateOperation(_ context.Context, _ quicstream.ConnInfo, facthash util.Hash) (bool, error)
}

type NetworkPolicy

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

func DefaultNetworkPolicy

func DefaultNetworkPolicy() NetworkPolicy

func (*NetworkPolicy) DecodeJSON

func (p *NetworkPolicy) DecodeJSON(b []byte, enc encoder.Encoder) error

func (NetworkPolicy) EmptyProposalNoBlock

func (p NetworkPolicy) EmptyProposalNoBlock() bool

func (NetworkPolicy) HashBytes

func (p NetworkPolicy) HashBytes() []byte

func (NetworkPolicy) IsValid

func (p NetworkPolicy) IsValid([]byte) error

func (NetworkPolicy) MarshalJSON

func (p NetworkPolicy) MarshalJSON() ([]byte, error)

func (NetworkPolicy) MaxOperationsInProposal

func (p NetworkPolicy) MaxOperationsInProposal() uint64

func (NetworkPolicy) MaxSuffrageSize

func (p NetworkPolicy) MaxSuffrageSize() uint64

func (*NetworkPolicy) SetEmptyProposalNoBlock

func (p *NetworkPolicy) SetEmptyProposalNoBlock(i bool) NetworkPolicy

func (*NetworkPolicy) SetMaxOperationsInProposal

func (p *NetworkPolicy) SetMaxOperationsInProposal(i uint64) NetworkPolicy

func (*NetworkPolicy) SetMaxSuffrageSize

func (p *NetworkPolicy) SetMaxSuffrageSize(i uint64) NetworkPolicy

func (*NetworkPolicy) SetSuffrageCandidateLifespan

func (p *NetworkPolicy) SetSuffrageCandidateLifespan(i base.Height) NetworkPolicy

func (*NetworkPolicy) SetSuffrageCandidateLimiterRule

func (p *NetworkPolicy) SetSuffrageCandidateLimiterRule(i base.SuffrageCandidateLimiterRule) NetworkPolicy

func (*NetworkPolicy) SetSuffrageExpelLifespan

func (p *NetworkPolicy) SetSuffrageExpelLifespan(i base.Height) NetworkPolicy

func (NetworkPolicy) SuffrageCandidateLifespan

func (p NetworkPolicy) SuffrageCandidateLifespan() base.Height

func (NetworkPolicy) SuffrageCandidateLimiterRule

func (p NetworkPolicy) SuffrageCandidateLimiterRule() base.SuffrageCandidateLimiterRule

func (NetworkPolicy) SuffrageExpelLifespan

func (p NetworkPolicy) SuffrageExpelLifespan() base.Height

type NetworkPolicyStateValue

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

func NewNetworkPolicyStateValue

func NewNetworkPolicyStateValue(policy base.NetworkPolicy) NetworkPolicyStateValue

func (*NetworkPolicyStateValue) DecodeJSON

func (s *NetworkPolicyStateValue) DecodeJSON(b []byte, enc encoder.Encoder) error

func (NetworkPolicyStateValue) HashBytes

func (s NetworkPolicyStateValue) HashBytes() []byte

func (NetworkPolicyStateValue) IsValid

func (s NetworkPolicyStateValue) IsValid([]byte) error

func (NetworkPolicyStateValue) MarshalJSON

func (s NetworkPolicyStateValue) MarshalJSON() ([]byte, error)

func (NetworkPolicyStateValue) Policy

type NetworkPolicyStateValueJSONMarshaler

type NetworkPolicyStateValueJSONMarshaler struct {
	Policy base.NetworkPolicy `json:"policy"`
	hint.BaseHinter
}

type NetworkPolicyStateValueJSONUnmarshaler

type NetworkPolicyStateValueJSONUnmarshaler struct {
	Policy json.RawMessage `json:"policy"`
}

type NewBlockWriterFunc

type NewBlockWriterFunc func(base.ProposalSignFact, base.GetStateFunc) (BlockWriter, error)

type NewOperationPool

type NewOperationPool interface {
	Operation(_ context.Context, operationhash util.Hash) (base.Operation, bool, error)
	OperationBytes(_ context.Context, operationhash util.Hash) (string, []byte, []byte, bool, error)
	OperationHashes(
		_ context.Context,
		_ base.Height,
		limit uint64,
		filter func(PoolOperationRecordMeta) (ok bool, err error),
	) ([][2]util.Hash, error)
	SetOperation(context.Context, base.Operation) (bool, error)
}

type NewOperationProcessorFunc

type NewOperationProcessorFunc func(base.Height, hint.Hint, base.GetStateFunc) (base.OperationProcessor, error)

type NewOperationProcessorInternalFunc

type NewOperationProcessorInternalFunc func(base.Height, base.GetStateFunc) (base.OperationProcessor, error)

type NodeConnInfo

type NodeConnInfo interface {
	base.Node
	network.ConnInfo
	ConnInfo() quicstream.ConnInfo
}

type NodeInConsensusNodesFunc

type NodeInConsensusNodesFunc func(base.Node, base.Height) (base.Suffrage, bool, error)

type NotProcessedACCEPTBallotFact

type NotProcessedACCEPTBallotFact struct {
	ACCEPTBallotFact
}

func NewNotProcessedACCEPTBallotFact

func NewNotProcessedACCEPTBallotFact(
	point base.Point,
	proposal util.Hash,
) NotProcessedACCEPTBallotFact

func (NotProcessedACCEPTBallotFact) ExpelFacts

func (fact NotProcessedACCEPTBallotFact) ExpelFacts() []util.Hash

func (NotProcessedACCEPTBallotFact) Point

func (fact NotProcessedACCEPTBallotFact) Point() base.StagePoint

func (NotProcessedACCEPTBallotFact) Stage

func (fact NotProcessedACCEPTBallotFact) Stage() base.Stage

type OperationProcessHandler

type OperationProcessHandler interface {
	Hints() []hint.Hint
	PreProcess(operation base.Operation) (bool, error)
	Process(operation base.Operation) ([]base.State, error)
}

type OperationProcessorGetOperationFunction

type OperationProcessorGetOperationFunction func(_ context.Context, operationhash, fact util.Hash) (
	base.Operation, error)

OperationProcessorGetOperationFunction works, - if operation is invalid, getOperation should return nil, ErrInvalidOperationInProcessor; it will be not processed and it's fact hash will be stored. - if operation not found in remote, getOperation should return nil, ErrOperationNotFoundInProcessor; it will be ignored. - if operation is known, return nil, ErrOperationAlreadyProcessedInProcessor; it will be ignored. - if operation fact not match with fact in proposal, return ErrNotProposalProcessorProcessed; it will stop processing proposal and makes wrong ACCEPT ballot for next round.

type Params

type Params struct {
	*util.BaseParams

	hint.BaseHinter
	// contains filtered or unexported fields
}

func DefaultParams

func DefaultParams(networkID base.NetworkID) *Params

func NewParams

func NewParams(networkID base.NetworkID) *Params

func (*Params) BallotStuckResolveAfter

func (p *Params) BallotStuckResolveAfter() time.Duration

func (*Params) BallotStuckWait

func (p *Params) BallotStuckWait() time.Duration

func (*Params) IntervalBroadcastBallot

func (p *Params) IntervalBroadcastBallot() time.Duration

func (*Params) IsValid

func (p *Params) IsValid(networkID []byte) error

func (*Params) MarshalJSON

func (p *Params) MarshalJSON() ([]byte, error)

func (*Params) MaxTryHandoverYBrokerSyncData

func (p *Params) MaxTryHandoverYBrokerSyncData() uint64

func (*Params) MinWaitNextBlockINITBallot

func (p *Params) MinWaitNextBlockINITBallot() time.Duration

MinWaitNextBlockINITBallot is used for waiting until the proposer creates new block for new proposal; Too short MinWaitNextBlockINITBallot may cause empty proposal.

func (*Params) NetworkID

func (p *Params) NetworkID() base.NetworkID

func (*Params) OperationPoolCacheSize

func (p *Params) OperationPoolCacheSize() int

func (*Params) SetBallotStuckResolveAfter

func (p *Params) SetBallotStuckResolveAfter(d time.Duration) error

func (*Params) SetBallotStuckWait

func (p *Params) SetBallotStuckWait(d time.Duration) error

func (*Params) SetIntervalBroadcastBallot

func (p *Params) SetIntervalBroadcastBallot(d time.Duration) error

func (*Params) SetMaxTryHandoverYBrokerSyncData

func (p *Params) SetMaxTryHandoverYBrokerSyncData(d uint64) error

func (*Params) SetMinWaitNextBlockINITBallot

func (p *Params) SetMinWaitNextBlockINITBallot(d time.Duration) error

func (*Params) SetNetworkID

func (p *Params) SetNetworkID(n base.NetworkID) error

func (*Params) SetOperationPoolCacheSize

func (p *Params) SetOperationPoolCacheSize(d int) error

func (*Params) SetStateCacheSize

func (p *Params) SetStateCacheSize(d int) error

func (*Params) SetThreshold

func (p *Params) SetThreshold(t base.Threshold) error

func (*Params) SetWaitPreparingINITBallot

func (p *Params) SetWaitPreparingINITBallot(d time.Duration) error

func (*Params) StateCacheSize

func (p *Params) StateCacheSize() int

func (*Params) Threshold

func (p *Params) Threshold() base.Threshold

func (*Params) UnmarshalJSON

func (p *Params) UnmarshalJSON(b []byte) error

func (*Params) WaitPreparingINITBallot

func (p *Params) WaitPreparingINITBallot() time.Duration

type PermanentDatabase

type PermanentDatabase interface {
	BaseDatabase
	Close() error
	Clean() error
	LastBlockMap() (base.BlockMap, bool, error)
	LastBlockMapBytes() (string, []byte, []byte, bool, error)
	LastSuffrageProof() (base.SuffrageProof, bool, error)
	LastSuffrageProofBytes() (string, []byte, []byte, bool, error)
	SuffrageProof(suffrageHeight base.Height) (base.SuffrageProof, bool, error)
	SuffrageProofBytes(suffrageHeight base.Height) (string, []byte, []byte, bool, error)
	SuffrageProofByBlockHeight(blockheight base.Height) (base.SuffrageProof, bool, error)
	BlockMap(base.Height) (base.BlockMap, bool, error)
	BlockMapBytes(base.Height) (string, []byte, []byte, bool, error)
	LastNetworkPolicy() base.NetworkPolicy
	MergeTempDatabase(context.Context, TempDatabase) error
}

PermanentDatabase stores some of block items permanently.

type PoolOperationRecordMeta

type PoolOperationRecordMeta interface {
	Version() [2]byte
	AddedAt() time.Time
	Hint() hint.Hint
	Operation() util.Hash
	Fact() util.Hash
}

type ProcessorProcessFunc

type ProcessorProcessFunc func(context.Context) (base.Manifest, error)

type ProposalFact

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

func NewProposalFact

func NewProposalFact(
	point base.Point,
	proposer base.Address,
	previousBlock util.Hash,
	operations [][2]util.Hash,
) ProposalFact

func (*ProposalFact) DecodeJSON

func (fact *ProposalFact) DecodeJSON(b []byte, enc encoder.Encoder) error

func (ProposalFact) IsValid

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

func (ProposalFact) MarshalJSON

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

func (ProposalFact) Operations

func (fact ProposalFact) Operations() [][2]util.Hash

func (ProposalFact) Point

func (fact ProposalFact) Point() base.Point

func (ProposalFact) PreviousBlock

func (fact ProposalFact) PreviousBlock() util.Hash

func (ProposalFact) ProposedAt

func (fact ProposalFact) ProposedAt() time.Time

func (ProposalFact) Proposer

func (fact ProposalFact) Proposer() base.Address

type ProposalMaker

type ProposalMaker struct {
	*logging.Logging

	sync.Mutex
	// contains filtered or unexported fields
}

func NewProposalMaker

func NewProposalMaker(
	local base.LocalNode,
	networkID base.NetworkID,
	getOperations func(context.Context, base.Height) ([][2]util.Hash, error),
	pool ProposalPool,
	lastBlockMap func() (base.BlockMap, bool, error),
) *ProposalMaker

func (*ProposalMaker) Make

func (p *ProposalMaker) Make(
	ctx context.Context, point base.Point, previousBlock util.Hash,
) (base.ProposalSignFact, error)

func (*ProposalMaker) PreferEmpty

func (p *ProposalMaker) PreferEmpty(
	ctx context.Context, point base.Point, previousBlock util.Hash,
) (base.ProposalSignFact, error)

type ProposalPool

type ProposalPool interface {
	Proposal(util.Hash) (base.ProposalSignFact, bool, error)
	ProposalBytes(util.Hash) (string, []byte, []byte, bool, error)
	ProposalByPoint(base.Point, base.Address, util.Hash) (base.ProposalSignFact, bool, error)
	SetProposal(pr base.ProposalSignFact) (bool, error)
}

type ProposalProcessor

type ProposalProcessor interface {
	Proposal() base.ProposalSignFact
	Process(context.Context, base.INITVoteproof) (base.Manifest, error)
	Save(context.Context, base.ACCEPTVoteproof) (base.BlockMap, error)
	Cancel() error
}

type ProposalProcessors

type ProposalProcessors struct {
	*logging.Logging

	sync.RWMutex
	// contains filtered or unexported fields
}

func (*ProposalProcessors) Cancel

func (pps *ProposalProcessors) Cancel() error

func (*ProposalProcessors) Process

func (pps *ProposalProcessors) Process(
	ctx context.Context,
	point base.Point,
	facthash util.Hash,
	previous base.Manifest,
	ivp base.INITVoteproof,
) (ProcessorProcessFunc, error)

func (*ProposalProcessors) Processor

func (pps *ProposalProcessors) Processor() ProposalProcessor

func (*ProposalProcessors) Save

func (pps *ProposalProcessors) Save(
	ctx context.Context, facthash util.Hash, avp base.ACCEPTVoteproof,
) (base.BlockMap, error)

func (*ProposalProcessors) SetRetryInterval

func (pps *ProposalProcessors) SetRetryInterval(i time.Duration) *ProposalProcessors

func (*ProposalProcessors) SetRetryLimit

func (pps *ProposalProcessors) SetRetryLimit(l int) *ProposalProcessors

type ProposalSelectFunc

type ProposalSelectFunc func(
	_ context.Context,
	_ base.Point,
	previousBlock util.Hash,
	wait time.Duration,
) (base.ProposalSignFact, error)

type ProposalSignFact

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

func NewProposalSignFact

func NewProposalSignFact(fact ProposalFact) ProposalSignFact

func (*ProposalSignFact) DecodeJSON

func (sf *ProposalSignFact) DecodeJSON(b []byte, enc encoder.Encoder) error

func (ProposalSignFact) Fact

func (sf ProposalSignFact) Fact() base.Fact

func (ProposalSignFact) HashBytes

func (sf ProposalSignFact) HashBytes() []byte

func (ProposalSignFact) IsValid

func (sf ProposalSignFact) IsValid(networkID []byte) error

func (ProposalSignFact) MarshalJSON

func (sf ProposalSignFact) MarshalJSON() ([]byte, error)

func (ProposalSignFact) Point

func (sf ProposalSignFact) Point() base.Point

func (ProposalSignFact) ProposalFact

func (sf ProposalSignFact) ProposalFact() base.ProposalFact

func (*ProposalSignFact) Sign

func (sf *ProposalSignFact) Sign(priv base.Privatekey, networkID base.NetworkID) error

func (ProposalSignFact) Signs

func (sf ProposalSignFact) Signs() []base.Sign

type ProposerSelectFunc

type ProposerSelectFunc func(context.Context, base.Point, []base.Node, util.Hash) (base.Node, error)

ProposerSelectFunc selects proposer between suffrage nodes. If failed to request proposal from remotes, local will be proposer.

type ReasonProcessedOperation

type ReasonProcessedOperation struct {
	base.Operation
	// contains filtered or unexported fields
}

func NewReasonProcessedOperation

func NewReasonProcessedOperation(
	op, facthash util.Hash, reason base.OperationProcessReasonError,
) ReasonProcessedOperation

func (ReasonProcessedOperation) FactHash

func (op ReasonProcessedOperation) FactHash() util.Hash

func (ReasonProcessedOperation) OperationHash

func (op ReasonProcessedOperation) OperationHash() util.Hash

func (ReasonProcessedOperation) Reason

type RemoteBlockItemReadFunc

type RemoteBlockItemReadFunc func(context.Context, url.URL, func(io.Reader) error) (bool, error)

func HTTPBlockItemReadFunc

func HTTPBlockItemReadFunc() RemoteBlockItemReadFunc

HTTPBlockItemReadFunc reads block item thru http, https. If there is `#https_insecure` fragment in url, connection has `InsecureSkipVerify` in tls.

type RemotesBlockItemReadFunc

type RemotesBlockItemReadFunc func(
	_ context.Context,
	uri url.URL,
	compressFormat string,
	callback func(_ io.Reader, compressFormat string) error,
) (known, found bool, _ error)

func NewDefaultRemotesBlockItemReadFunc

func NewDefaultRemotesBlockItemReadFunc() RemotesBlockItemReadFunc

type StateCacheSetter

type StateCacheSetter interface {
	SetStateCache(util.GCache[string, [2]interface{}])
}

type Suffrage

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

func NewSuffrage

func NewSuffrage(nodes []base.Node) (Suffrage, error)

func (Suffrage) Exists

func (suf Suffrage) Exists(node base.Address) bool

func (Suffrage) ExistsPublickey

func (suf Suffrage) ExistsPublickey(node base.Address, pub base.Publickey) bool

func (Suffrage) Len

func (suf Suffrage) Len() int

func (Suffrage) MarshalJSON

func (suf Suffrage) MarshalJSON() ([]byte, error)

func (Suffrage) Nodes

func (suf Suffrage) Nodes() []base.Node

type SuffrageCandidateJSONMarshaler

type SuffrageCandidateJSONMarshaler struct {
	Node base.Node `json:"node"`
	hint.BaseHinter
	Start    base.Height `json:"start"`
	Deadline base.Height `json:"deadline"`
}

type SuffrageCandidateJSONUnmarshaler

type SuffrageCandidateJSONUnmarshaler struct {
	Node     json.RawMessage    `json:"node"`
	Start    base.HeightDecoder `json:"start"`
	Deadline base.HeightDecoder `json:"deadline"`
}

type SuffrageCandidateStateValue

type SuffrageCandidateStateValue struct {
	base.Node
	hint.BaseHinter
	// contains filtered or unexported fields
}

func NewSuffrageCandidateStateValue

func NewSuffrageCandidateStateValue(node base.Node, start, deadline base.Height) SuffrageCandidateStateValue

func (SuffrageCandidateStateValue) Deadline

func (suf SuffrageCandidateStateValue) Deadline() base.Height

func (*SuffrageCandidateStateValue) DecodeJSON

func (suf *SuffrageCandidateStateValue) DecodeJSON(b []byte, enc encoder.Encoder) error

func (SuffrageCandidateStateValue) HashBytes

func (suf SuffrageCandidateStateValue) HashBytes() []byte

func (SuffrageCandidateStateValue) IsValid

func (suf SuffrageCandidateStateValue) IsValid([]byte) error

func (SuffrageCandidateStateValue) MarshalJSON

func (suf SuffrageCandidateStateValue) MarshalJSON() ([]byte, error)

func (SuffrageCandidateStateValue) Start

type SuffrageCandidatesStateValue

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

func (*SuffrageCandidatesStateValue) DecodeJSON

func (s *SuffrageCandidatesStateValue) DecodeJSON(b []byte, enc encoder.Encoder) error

func (SuffrageCandidatesStateValue) HashBytes

func (s SuffrageCandidatesStateValue) HashBytes() []byte

func (SuffrageCandidatesStateValue) IsValid

func (SuffrageCandidatesStateValue) MarshalJSON

func (s SuffrageCandidatesStateValue) MarshalJSON() ([]byte, error)

func (SuffrageCandidatesStateValue) Nodes

type SuffrageConfirmBallotFact

type SuffrageConfirmBallotFact struct {
	INITBallotFact
}

func NewSuffrageConfirmBallotFact

func NewSuffrageConfirmBallotFact(
	point base.Point,
	previousBlock, proposal util.Hash,
	expelfacts []util.Hash,
) SuffrageConfirmBallotFact

func (SuffrageConfirmBallotFact) ExpelFacts

func (fact SuffrageConfirmBallotFact) ExpelFacts() []util.Hash

func (SuffrageConfirmBallotFact) IsValid

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

func (SuffrageConfirmBallotFact) Point

func (fact SuffrageConfirmBallotFact) Point() base.StagePoint

func (SuffrageConfirmBallotFact) Stage

func (fact SuffrageConfirmBallotFact) Stage() base.Stage

type SuffrageExpelFact

type SuffrageExpelFact struct {
	base.BaseFact
	// contains filtered or unexported fields
}

func NewSuffrageExpelFact

func NewSuffrageExpelFact(
	node base.Address,
	start base.Height,
	end base.Height,
	reason string,
) SuffrageExpelFact

func (*SuffrageExpelFact) DecodeJSON

func (fact *SuffrageExpelFact) DecodeJSON(b []byte, enc encoder.Encoder) error

func (SuffrageExpelFact) ExpelEnd

func (fact SuffrageExpelFact) ExpelEnd() base.Height

func (SuffrageExpelFact) ExpelStart

func (fact SuffrageExpelFact) ExpelStart() base.Height

func (SuffrageExpelFact) IsValid

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

func (SuffrageExpelFact) MarshalJSON

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

func (SuffrageExpelFact) Node

func (fact SuffrageExpelFact) Node() base.Address

func (SuffrageExpelFact) Reason

func (fact SuffrageExpelFact) Reason() string

type SuffrageExpelOperation

type SuffrageExpelOperation struct {
	base.BaseNodeOperation
}

func NewSuffrageExpelOperation

func NewSuffrageExpelOperation(fact SuffrageExpelFact) SuffrageExpelOperation

func (SuffrageExpelOperation) ExpelFact

func (SuffrageExpelOperation) IsValid

func (op SuffrageExpelOperation) IsValid(networkID []byte) error

func (SuffrageExpelOperation) NodeSigns

func (op SuffrageExpelOperation) NodeSigns() []base.NodeSign

func (*SuffrageExpelOperation) SetToken

func (op *SuffrageExpelOperation) SetToken(base.Token) error

type SuffrageExpelPool

type SuffrageExpelPool interface {
	SuffrageExpelOperation(base.Height, base.Address) (base.SuffrageExpelOperation, bool, error)
	SetSuffrageExpelOperation(base.SuffrageExpelOperation) error
	TraverseSuffrageExpelOperations(
		context.Context,
		base.Height,
		SuffrageVoteFunc,
	) error
	RemoveSuffrageExpelOperationsByFact([]base.SuffrageExpelFact) error
	RemoveSuffrageExpelOperationsByHeight(base.Height) error
}

type SuffrageNodeStateValue

type SuffrageNodeStateValue struct {
	base.Node
	hint.BaseHinter
	// contains filtered or unexported fields
}

func NewSuffrageNodeStateValue

func NewSuffrageNodeStateValue(node base.Node, start base.Height) SuffrageNodeStateValue

func (*SuffrageNodeStateValue) DecodeJSON

func (s *SuffrageNodeStateValue) DecodeJSON(b []byte, enc encoder.Encoder) error

func (SuffrageNodeStateValue) HashBytes

func (s SuffrageNodeStateValue) HashBytes() []byte

func (SuffrageNodeStateValue) Hint

func (s SuffrageNodeStateValue) Hint() hint.Hint

func (SuffrageNodeStateValue) IsValid

func (s SuffrageNodeStateValue) IsValid([]byte) error

func (SuffrageNodeStateValue) MarshalJSON

func (s SuffrageNodeStateValue) MarshalJSON() ([]byte, error)

func (SuffrageNodeStateValue) Start

type SuffrageNodesStateValue

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

func NewSuffrageNodesStateValue

func NewSuffrageNodesStateValue(
	suffrageheight base.Height, nodes []base.SuffrageNodeStateValue,
) SuffrageNodesStateValue

func (*SuffrageNodesStateValue) DecodeJSON

func (s *SuffrageNodesStateValue) DecodeJSON(b []byte, enc encoder.Encoder) error

func (SuffrageNodesStateValue) HashBytes

func (s SuffrageNodesStateValue) HashBytes() []byte

func (SuffrageNodesStateValue) Height

func (s SuffrageNodesStateValue) Height() base.Height

func (SuffrageNodesStateValue) IsValid

func (s SuffrageNodesStateValue) IsValid([]byte) error

func (SuffrageNodesStateValue) MarshalJSON

func (s SuffrageNodesStateValue) MarshalJSON() ([]byte, error)

func (SuffrageNodesStateValue) Nodes

func (SuffrageNodesStateValue) Suffrage

func (s SuffrageNodesStateValue) Suffrage() (base.Suffrage, error)

type SuffrageStateBuilder

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

SuffrageStateBuilder tries to sync suffrage states from remote nodes. It will rebuild the entire suffrage states history. SuffrageProof from getSuffrageProof should be valid(IsValid()).

func NewSuffrageStateBuilder

func NewSuffrageStateBuilder(
	networkID base.NetworkID,
	lastSuffrageProof GetLastSuffrageProofFromRemoteFunc,
	getSuffrageProof GetSuffrageProofFromRemoteFunc,
	lastSuffrageCandidateState GetLastSuffrageCandidateStateRemoteFunc,
) *SuffrageStateBuilder

func (*SuffrageStateBuilder) Build

func (s *SuffrageStateBuilder) Build(
	ctx context.Context, localstate base.State,
) (lastheight base.Height, proofs []base.SuffrageProof, candidates base.State, _ error)

Build builds latest suffrage states from localstate.

type SuffrageVoteFunc

type SuffrageVoteFunc func(base.SuffrageExpelOperation) (bool, error)

type SuffrageVoting

type SuffrageVoting struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewSuffrageVoting

func NewSuffrageVoting(
	local base.Address,
	db SuffrageExpelPool,
	existsInState func(util.Hash) (bool, error),
	votedCallback func(base.SuffrageExpelOperation) error,
) *SuffrageVoting

func (*SuffrageVoting) Find

func (*SuffrageVoting) Vote

type SyncSourcePool

type SyncSourcePool struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewSyncSourcePool

func NewSyncSourcePool(fixed []NodeConnInfo) *SyncSourcePool

func (*SyncSourcePool) Actives

func (p *SyncSourcePool) Actives(f func(NodeConnInfo) bool)

func (*SyncSourcePool) AddNonFixed

func (p *SyncSourcePool) AddNonFixed(ncis ...NodeConnInfo) bool

func (*SyncSourcePool) IsInFixed

func (p *SyncSourcePool) IsInFixed(node base.Address) bool

func (*SyncSourcePool) IsInNonFixed

func (p *SyncSourcePool) IsInNonFixed(node base.Address) bool

func (*SyncSourcePool) Len

func (p *SyncSourcePool) Len() int

func (*SyncSourcePool) NodeConnInfo

func (p *SyncSourcePool) NodeConnInfo(node base.Address) []NodeConnInfo

func (*SyncSourcePool) NodeExists

func (p *SyncSourcePool) NodeExists(node base.Address) bool

func (*SyncSourcePool) Pick

func (p *SyncSourcePool) Pick() (NodeConnInfo, func(error), error)

func (*SyncSourcePool) PickMultiple

func (p *SyncSourcePool) PickMultiple(n int) ([]NodeConnInfo, []func(error), error)

func (*SyncSourcePool) RemoveNonFixed

func (p *SyncSourcePool) RemoveNonFixed(nci NodeConnInfo) bool

func (*SyncSourcePool) RemoveNonFixedNode

func (p *SyncSourcePool) RemoveNonFixedNode(nodes ...base.Address) bool

func (*SyncSourcePool) Retry

func (p *SyncSourcePool) Retry(
	ctx context.Context,
	f func(NodeConnInfo) (bool, error),
	limit int,
	interval time.Duration,
) error

func (*SyncSourcePool) Traverse

func (p *SyncSourcePool) Traverse(f func(NodeConnInfo) bool)

func (*SyncSourcePool) UpdateFixed

func (p *SyncSourcePool) UpdateFixed(fixed []NodeConnInfo) bool

type Syncer

type Syncer interface {
	util.Daemon
	Add(base.Height) bool
	Finished() <-chan base.Height
	Done() <-chan struct{} // revive:disable-line:nested-structs
	Err() error
	IsFinished() (base.Height, bool)
	Cancel() error
}

type TempDatabase

type TempDatabase interface {
	BaseDatabase
	Height() base.Height
	Close() error
	Remove() error
	Merge() error
	LastBlockMap() (base.BlockMap, bool, error)
	BlockMapBytes() (string, []byte, []byte, error)
	SuffrageHeight() base.Height
	SuffrageProof() (base.SuffrageProof, bool, error)
	LastSuffrageProofBytes() (string, []byte, []byte, bool, error)
	NetworkPolicy() base.NetworkPolicy
}

TempDatabase is the temporary database; it contains only blockmap and others of one block for storing some of block items fast.

type TempSyncPool

type TempSyncPool interface {
	BlockMap(base.Height) (base.BlockMap, bool, error)
	SetBlockMap(base.BlockMap) error
	Cancel() error
	Close() error
}

Directories

Path Synopsis
Package isaacblock handles data of block.
Package isaacblock handles data of block.
Package isaacdatabase handles data for isaac
Package isaacdatabase handles data for isaac
Package isaacnetwork provides network.
Package isaacnetwork provides network.
Package isaacoperation provides the base operations.
Package isaacoperation provides the base operations.
Package isaacstates handles node states
Package isaacstates handles node states

Jump to

Keyboard shortcuts

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