choices

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: BSD-3-Clause Imports: 5 Imported by: 135

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decidable

type Decidable interface {
	// ID returns a unique ID for this element.
	//
	// Typically, this is implemented by using a cryptographic hash of a
	// binary representation of this element. An element should return the same
	// IDs upon repeated calls.
	ID() ids.ID

	// Accept this element.
	//
	// This element will be accepted by every correct node in the network.
	// All subsequent Status calls return Accepted.
	Accept(context.Context) error

	// Reject this element.
	//
	// This element will not be accepted by any correct node in the network.
	// All subsequent Status calls return Rejected.
	Reject(context.Context) error

	// Status returns this element's current status.
	//
	// If Accept has been called on an element with this ID, Accepted should be
	// returned. Similarly, if Reject has been called on an element with this
	// ID, Rejected should be returned. If the contents of this element are
	// unknown, then Unknown should be returned. Otherwise, Processing should be
	// returned.
	//
	// TODO: Consider allowing Status to return an error.
	Status() Status
}

Decidable represents element that can be decided.

Decidable objects are typically thought of as either transactions, blocks, or vertices.

type Status

type Status uint32
const (
	Unknown Status = iota
	Processing
	Rejected
	Accepted
)

List of possible status values Unknown Zero value, means the operation is not known Processing means the operation is known, but hasn't been decided yet Rejected means the operation will never be accepted Accepted means the operation was accepted

func (Status) Bytes

func (s Status) Bytes() []byte

Bytes returns the byte repr. of this status

func (Status) Decided

func (s Status) Decided() bool

Decided returns true if the status is Rejected or Accepted.

func (Status) Fetched

func (s Status) Fetched() bool

Fetched returns true if the status has been set.

func (Status) MarshalJSON

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

func (Status) String

func (s Status) String() string

func (*Status) UnmarshalJSON

func (s *Status) UnmarshalJSON(b []byte) error

func (Status) Valid

func (s Status) Valid() error

Valid returns nil if the status is a valid status.

type TestDecidable added in v0.8.0

type TestDecidable struct {
	IDV              ids.ID
	AcceptV, RejectV error
	StatusV          Status
}

TestDecidable is a test Decidable

func (*TestDecidable) Accept added in v0.8.0

func (d *TestDecidable) Accept(context.Context) error

func (*TestDecidable) ID added in v0.8.0

func (d *TestDecidable) ID() ids.ID

func (*TestDecidable) Reject added in v0.8.0

func (d *TestDecidable) Reject(context.Context) error

func (*TestDecidable) SetStatus added in v1.11.5

func (d *TestDecidable) SetStatus(status Status)

func (*TestDecidable) Status added in v0.8.0

func (d *TestDecidable) Status() Status

Jump to

Keyboard shortcuts

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