Documentation ¶
Index ¶
- type Consensus
- type Factory
- type Parameters
- type TestVertex
- func (v *TestVertex) Bytes() []byte
- func (v *TestVertex) HasWhitelist() bool
- func (v *TestVertex) Height() (uint64, error)
- func (v *TestVertex) Parents() ([]Vertex, error)
- func (v *TestVertex) Txs(context.Context) ([]snowstorm.Tx, error)
- func (v *TestVertex) Verify(context.Context) error
- func (v *TestVertex) Whitelist(context.Context) (set.Set[ids.ID], error)
- type Topological
- func (ta *Topological) Add(ctx context.Context, vtx Vertex) error
- func (ta *Topological) Finalized() bool
- func (ta *Topological) HealthCheck(ctx context.Context) (interface{}, error)
- func (ta *Topological) Initialize(ctx context.Context, chainCtx *snow.ConsensusContext, params Parameters, ...) error
- func (ta *Topological) IsVirtuous(tx snowstorm.Tx) bool
- func (ta *Topological) NumProcessing() int
- func (ta *Topological) Orphans() set.Set[ids.ID]
- func (ta *Topological) Preferences() set.Set[ids.ID]
- func (ta *Topological) Quiesce() bool
- func (ta *Topological) RecordPoll(ctx context.Context, responses ids.UniqueBag) error
- func (ta *Topological) TxIssued(tx snowstorm.Tx) bool
- func (ta *Topological) VertexIssued(vtx Vertex) bool
- func (ta *Topological) Virtuous() set.Set[ids.ID]
- type TopologicalFactory
- type Vertex
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Consensus ¶
type Consensus interface { health.Checker // Takes in alpha, beta1, beta2, the accepted frontier, the join statuses, // the mutation statuses, and the consumer statuses. If accept or reject is // called, the status maps should be immediately updated accordingly. // Assumes each element in the accepted frontier will return accepted from // the join status map. Initialize(context.Context, *snow.ConsensusContext, Parameters, []Vertex) error // Returns the number of vertices processing NumProcessing() int // Returns true if the transaction is virtuous. // That is, no transaction has been added that conflicts with it IsVirtuous(snowstorm.Tx) bool // Adds a new decision. Assumes the dependencies have already been added. // Assumes that mutations don't conflict with themselves. Returns if a // critical error has occurred. Add(context.Context, Vertex) error // VertexIssued returns true iff Vertex has been added VertexIssued(Vertex) bool // TxIssued returns true if a vertex containing this transaction has been added TxIssued(snowstorm.Tx) bool // Returns the set of transaction IDs that are virtuous but not contained in // any preferred vertices. Orphans() set.Set[ids.ID] // Returns a set of vertex IDs that were virtuous at the last update. Virtuous() set.Set[ids.ID] // Returns a set of vertex IDs that are preferred Preferences() set.Set[ids.ID] // RecordPoll collects the results of a network poll. If a result has not // been added, the result is dropped. Returns if a critical error has // occurred. RecordPoll(context.Context, ids.UniqueBag) error // Quiesce is guaranteed to return true if the instance is finalized. It // may, but doesn't need to, return true if all processing vertices are // rogue. It must return false if there is a virtuous vertex that is still // processing. Quiesce() bool // Finalized returns true if all transactions that have been added have been // finalized. Note, it is possible that after returning finalized, a new // decision may be added such that this instance is no longer finalized. Finalized() bool }
Consensus represents a general avalanche instance that can be used directly to process a series of partially ordered elements.
type Factory ¶
type Factory interface {
New() Consensus
}
Factory returns new instances of Consensus
type Parameters ¶
type Parameters struct { snowball.Parameters Parents int `json:"parents" yaml:"parents"` BatchSize int `json:"batchSize" yaml:"batchSize"` }
Parameters the avalanche parameters include the snowball parameters and the optimal number of parents
func (Parameters) Valid ¶
func (p Parameters) Valid() error
Valid returns nil if the parameters describe a valid initialization.
type TestVertex ¶ added in v0.8.0
type TestVertex struct { choices.TestDecidable VerifyErrV error ParentsV []Vertex ParentsErrV error HasWhitelistV bool WhitelistV set.Set[ids.ID] WhitelistErrV error HeightV uint64 HeightErrV error TxsV []snowstorm.Tx TxsErrV error BytesV []byte }
TestVertex is a useful test vertex
func (*TestVertex) Bytes ¶ added in v0.8.0
func (v *TestVertex) Bytes() []byte
func (*TestVertex) HasWhitelist ¶ added in v1.7.6
func (v *TestVertex) HasWhitelist() bool
func (*TestVertex) Height ¶ added in v0.8.0
func (v *TestVertex) Height() (uint64, error)
func (*TestVertex) Parents ¶ added in v0.8.0
func (v *TestVertex) Parents() ([]Vertex, error)
type Topological ¶
Topological performs the avalanche algorithm by utilizing a topological sort of the voting results. Assumes that vertices are inserted in topological order.
func (*Topological) Finalized ¶
func (ta *Topological) Finalized() bool
func (*Topological) HealthCheck ¶ added in v1.2.2
func (ta *Topological) HealthCheck(ctx context.Context) (interface{}, error)
HealthCheck returns information about the consensus health.
func (*Topological) Initialize ¶
func (ta *Topological) Initialize( ctx context.Context, chainCtx *snow.ConsensusContext, params Parameters, frontier []Vertex, ) error
func (*Topological) IsVirtuous ¶
func (ta *Topological) IsVirtuous(tx snowstorm.Tx) bool
func (*Topological) NumProcessing ¶ added in v1.2.0
func (ta *Topological) NumProcessing() int
func (*Topological) Preferences ¶
func (ta *Topological) Preferences() set.Set[ids.ID]
func (*Topological) Quiesce ¶
func (ta *Topological) Quiesce() bool
func (*Topological) RecordPoll ¶
func (*Topological) VertexIssued ¶
func (ta *Topological) VertexIssued(vtx Vertex) bool
type TopologicalFactory ¶
type TopologicalFactory struct{}
TopologicalFactory implements Factory by returning a topological struct
func (TopologicalFactory) New ¶
func (TopologicalFactory) New() Consensus
type Vertex ¶
type Vertex interface { choices.Decidable snowstorm.Whitelister // Vertex verification should be performed before issuance. Verify(context.Context) error // Returns the vertices this vertex depends on Parents() ([]Vertex, error) // Returns the height of this vertex. A vertex's height is defined by one // greater than the maximum height of the parents. Height() (uint64, error) // Returns a series of state transitions to be performed on acceptance Txs(context.Context) ([]snowstorm.Tx, error) // Returns the binary representation of this vertex Bytes() []byte }
Vertex is a collection of multiple transactions tied to other vertices