Documentation ¶
Index ¶
- Constants
- type AcceptedHandler
- type AcceptedSender
- type Bootstrapable
- type BootstrapableTest
- type Bootstrapper
- func (b *Bootstrapper) Accepted(validatorID ids.ShortID, requestID uint32, containerIDs ids.Set)
- func (b *Bootstrapper) AcceptedFrontier(validatorID ids.ShortID, requestID uint32, containerIDs ids.Set)
- func (b *Bootstrapper) GetAccepted(validatorID ids.ShortID, requestID uint32, containerIDs ids.Set)
- func (b *Bootstrapper) GetAcceptedFailed(validatorID ids.ShortID, requestID uint32)
- func (b *Bootstrapper) GetAcceptedFrontier(validatorID ids.ShortID, requestID uint32)
- func (b *Bootstrapper) GetAcceptedFrontierFailed(validatorID ids.ShortID, requestID uint32)
- func (b *Bootstrapper) Initialize(config Config)
- func (b *Bootstrapper) Startup()
- type Config
- type Engine
- type EngineTest
- func (e *EngineTest) Accepted(validatorID ids.ShortID, requestID uint32, containerIDs ids.Set)
- func (e *EngineTest) AcceptedFrontier(validatorID ids.ShortID, requestID uint32, containerIDs ids.Set)
- func (e *EngineTest) Chits(validatorID ids.ShortID, requestID uint32, containerIDs ids.Set)
- func (e *EngineTest) Context() *snow.Context
- func (e *EngineTest) Default(cant bool)
- func (e *EngineTest) Get(validatorID ids.ShortID, requestID uint32, containerID ids.ID)
- func (e *EngineTest) GetAccepted(validatorID ids.ShortID, requestID uint32, containerIDs ids.Set)
- func (e *EngineTest) GetAcceptedFailed(validatorID ids.ShortID, requestID uint32)
- func (e *EngineTest) GetAcceptedFrontier(validatorID ids.ShortID, requestID uint32)
- func (e *EngineTest) GetAcceptedFrontierFailed(validatorID ids.ShortID, requestID uint32)
- func (e *EngineTest) GetFailed(validatorID ids.ShortID, requestID uint32, containerID ids.ID)
- func (e *EngineTest) Notify(msg Message)
- func (e *EngineTest) PullQuery(validatorID ids.ShortID, requestID uint32, containerID ids.ID)
- func (e *EngineTest) PushQuery(validatorID ids.ShortID, requestID uint32, containerID ids.ID, ...)
- func (e *EngineTest) Put(validatorID ids.ShortID, requestID uint32, containerID ids.ID, ...)
- func (e *EngineTest) QueryFailed(validatorID ids.ShortID, requestID uint32)
- func (e *EngineTest) Shutdown()
- func (e *EngineTest) Startup()
- type ExternalHandler
- type FetchHandler
- type FetchSender
- type FrontierHandler
- type FrontierSender
- type Fx
- type HTTPHandler
- type Handler
- type InternalHandler
- type LockOption
- type Message
- type QueryHandler
- type QuerySender
- type Sender
- type SenderTest
- func (s *SenderTest) Accepted(validatorID ids.ShortID, requestID uint32, containerIDs ids.Set)
- func (s *SenderTest) AcceptedFrontier(validatorID ids.ShortID, requestID uint32, containerIDs ids.Set)
- func (s *SenderTest) Chits(vdr ids.ShortID, requestID uint32, votes ids.Set)
- func (s *SenderTest) Default(cant bool)
- func (s *SenderTest) Get(vdr ids.ShortID, requestID uint32, vtxID ids.ID)
- func (s *SenderTest) GetAccepted(validatorIDs ids.ShortSet, requestID uint32, containerIDs ids.Set)
- func (s *SenderTest) GetAcceptedFrontier(validatorIDs ids.ShortSet, requestID uint32)
- func (s *SenderTest) PullQuery(vdrs ids.ShortSet, requestID uint32, vtxID ids.ID)
- func (s *SenderTest) PushQuery(vdrs ids.ShortSet, requestID uint32, vtxID ids.ID, vtx []byte)
- func (s *SenderTest) Put(vdr ids.ShortID, requestID uint32, vtxID ids.ID, vtx []byte)
- type StaticVM
- type VM
- type VMTest
Constants ¶
const ( WriteLock = iota ReadLock NoLock )
List of all allowed options
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AcceptedHandler ¶
type AcceptedHandler interface { // GetAccepted notifies this consensus engine that it should send the set of // containerIDs that it has accepted from the provided set to the specified // validator GetAccepted(validatorID ids.ShortID, requestID uint32, containerIDs ids.Set) // Accepted notifies this consensus engine of a set of accepted containerIDs Accepted(validatorID ids.ShortID, requestID uint32, containerIDs ids.Set) // GetAcceptedFailed notifies this consensus engine that the requested // accepted containers requested from the specified validator should be // considered lost GetAcceptedFailed(validatorID ids.ShortID, requestID uint32) }
AcceptedHandler defines how a consensus engine reacts to messages pertaining to accepted containers from other validators
type AcceptedSender ¶
type AcceptedSender interface { // GetAccepted requests that every validator in [validatorIDs] sends an // Accepted message with all the IDs in [containerIDs] that the validator // thinks is accepted. GetAccepted(validatorIDs ids.ShortSet, requestID uint32, containerIDs ids.Set) // Accepted responds to a GetAccepted message with a set of IDs of // containers that are accepted. Accepted(validatorID ids.ShortID, requestID uint32, containerIDs ids.Set) }
AcceptedSender defines how a consensus engine sends messages pertaining to accepted containers
type Bootstrapable ¶
type Bootstrapable interface { // Returns the set of containerIDs that are accepted, but have no accepted // children. CurrentAcceptedFrontier() ids.Set // Returns the subset of containerIDs that are accepted by this chain. FilterAccepted(containerIDs ids.Set) (acceptedContainerIDs ids.Set) // Force the provided containers to be accepted. ForceAccepted(acceptedContainerIDs ids.Set) }
Bootstrapable defines the functionality required to support bootstrapping
type BootstrapableTest ¶
type BootstrapableTest struct { T *testing.T CantCurrentAcceptedFrontier, CantFilterAccepted, CantForceAccepted bool CurrentAcceptedFrontierF func() (acceptedContainerIDs ids.Set) FilterAcceptedF func(containerIDs ids.Set) (acceptedContainerIDs ids.Set) ForceAcceptedF func(acceptedContainerIDs ids.Set) }
BootstrapableTest is a test engine that supports bootstrapping
func (*BootstrapableTest) CurrentAcceptedFrontier ¶
func (b *BootstrapableTest) CurrentAcceptedFrontier() ids.Set
CurrentAcceptedFrontier implements the Bootstrapable interface
func (*BootstrapableTest) Default ¶
func (b *BootstrapableTest) Default(cant bool)
Default sets the default on call handling
func (*BootstrapableTest) FilterAccepted ¶
func (b *BootstrapableTest) FilterAccepted(containerIDs ids.Set) ids.Set
FilterAccepted implements the Bootstrapable interface
func (*BootstrapableTest) ForceAccepted ¶
func (b *BootstrapableTest) ForceAccepted(containerIDs ids.Set)
ForceAccepted implements the Bootstrapable interface
type Bootstrapper ¶
Bootstrapper implements the Engine interface.
func (*Bootstrapper) AcceptedFrontier ¶
func (b *Bootstrapper) AcceptedFrontier(validatorID ids.ShortID, requestID uint32, containerIDs ids.Set)
AcceptedFrontier implements the Engine interface.
func (*Bootstrapper) GetAccepted ¶
GetAccepted implements the Engine interface.
func (*Bootstrapper) GetAcceptedFailed ¶
func (b *Bootstrapper) GetAcceptedFailed(validatorID ids.ShortID, requestID uint32)
GetAcceptedFailed implements the Engine interface.
func (*Bootstrapper) GetAcceptedFrontier ¶
func (b *Bootstrapper) GetAcceptedFrontier(validatorID ids.ShortID, requestID uint32)
GetAcceptedFrontier implements the Engine interface.
func (*Bootstrapper) GetAcceptedFrontierFailed ¶
func (b *Bootstrapper) GetAcceptedFrontierFailed(validatorID ids.ShortID, requestID uint32)
GetAcceptedFrontierFailed implements the Engine interface.
func (*Bootstrapper) Initialize ¶
func (b *Bootstrapper) Initialize(config Config)
Initialize implements the Engine interface.
func (*Bootstrapper) Startup ¶
func (b *Bootstrapper) Startup()
Startup implements the Engine interface.
type Config ¶
type Config struct { Context *snow.Context Validators validators.Set Beacons validators.Set Alpha uint64 Sender Sender Bootstrapable Bootstrapable }
Config wraps the common configurations that are needed by a Snow consensus engine
func DefaultConfigTest ¶
func DefaultConfigTest() Config
DefaultConfigTest returns a test configuration
type Engine ¶
type Engine interface { Handler // Return the context of the chain this engine is working on Context() *snow.Context }
Engine describes the standard interface of a consensus engine
type EngineTest ¶
type EngineTest struct { T *testing.T CantStartup, CantShutdown, CantContext, CantNotify, CantGetAcceptedFrontier, CantGetAcceptedFrontierFailed, CantAcceptedFrontier, CantGetAccepted, CantGetAcceptedFailed, CantAccepted, CantGet, CantGetFailed, CantPut, CantPushQuery, CantPullQuery, CantQueryFailed, CantChits bool StartupF, ShutdownF func() ContextF func() *snow.Context NotifyF func(Message) GetF, GetFailedF, PullQueryF func(validatorID ids.ShortID, requestID uint32, containerID ids.ID) PutF, PushQueryF func(validatorID ids.ShortID, requestID uint32, containerID ids.ID, container []byte) GetAcceptedFrontierF, GetAcceptedFrontierFailedF, GetAcceptedFailedF, QueryFailedF func(validatorID ids.ShortID, requestID uint32) AcceptedFrontierF, GetAcceptedF, AcceptedF, ChitsF func(validatorID ids.ShortID, requestID uint32, containerIDs ids.Set) }
EngineTest is a test engine
func (*EngineTest) AcceptedFrontier ¶
func (e *EngineTest) AcceptedFrontier(validatorID ids.ShortID, requestID uint32, containerIDs ids.Set)
AcceptedFrontier ...
func (*EngineTest) GetAccepted ¶
GetAccepted ...
func (*EngineTest) GetAcceptedFailed ¶
func (e *EngineTest) GetAcceptedFailed(validatorID ids.ShortID, requestID uint32)
GetAcceptedFailed ...
func (*EngineTest) GetAcceptedFrontier ¶
func (e *EngineTest) GetAcceptedFrontier(validatorID ids.ShortID, requestID uint32)
GetAcceptedFrontier ...
func (*EngineTest) GetAcceptedFrontierFailed ¶
func (e *EngineTest) GetAcceptedFrontierFailed(validatorID ids.ShortID, requestID uint32)
GetAcceptedFrontierFailed ...
func (*EngineTest) PushQuery ¶
func (e *EngineTest) PushQuery(validatorID ids.ShortID, requestID uint32, containerID ids.ID, container []byte)
PushQuery ...
func (*EngineTest) Put ¶
func (e *EngineTest) Put(validatorID ids.ShortID, requestID uint32, containerID ids.ID, container []byte)
Put ...
func (*EngineTest) QueryFailed ¶
func (e *EngineTest) QueryFailed(validatorID ids.ShortID, requestID uint32)
QueryFailed ...
type ExternalHandler ¶
type ExternalHandler interface { FrontierHandler AcceptedHandler FetchHandler QueryHandler }
ExternalHandler defines how a consensus engine reacts to messages and requests from other validators
type FetchHandler ¶
type FetchHandler interface { // Get notifies this consensus engine that the specified validator requested // that this engine send the specified container to it Get(validatorID ids.ShortID, requestID uint32, containerID ids.ID) // Put the container with the specified ID and body. // This engine needs to request and receive missing ancestors of the // container before adding the container to consensus. Once all ancestor // containers are added, pushes the container into the consensus. Put(validatorID ids.ShortID, requestID uint32, containerID ids.ID, container []byte) // Notify this engine that a get request it issued has failed. GetFailed(validatorID ids.ShortID, requestID uint32, containerID ids.ID) }
FetchHandler defines how a consensus engine reacts to retrieval messages from other validators
type FetchSender ¶
type FetchSender interface { // Request a container from a validator. // Request that the specified validator send the specified container // to this validator Get(validatorID ids.ShortID, requestID uint32, containerID ids.ID) // Tell the specified validator that the container whose ID is <containerID> // has body <container> Put(validatorID ids.ShortID, requestID uint32, containerID ids.ID, container []byte) }
FetchSender defines how a consensus engine sends retrieval messages to other validators
type FrontierHandler ¶
type FrontierHandler interface { // GetAcceptedFrontier notifies this consensus engine that its accepted // frontier is requested by the specified validator GetAcceptedFrontier(validatorID ids.ShortID, requestID uint32) // AcceptedFrontier notifies this consensus engine of the specified // validators current accepted frontier AcceptedFrontier(validatorID ids.ShortID, requestID uint32, containerIDs ids.Set) // GetAcceptedFrontierFailed notifies this consensus engine that the // requested accepted frontier from the specified validator should be // considered lost GetAcceptedFrontierFailed(validatorID ids.ShortID, requestID uint32) }
FrontierHandler defines how a consensus engine reacts to frontier messages from other validators
type FrontierSender ¶
type FrontierSender interface { // GetAcceptedFrontier requests that every validator in [validatorIDs] sends // an AcceptedFrontier message. GetAcceptedFrontier(validatorIDs ids.ShortSet, requestID uint32) // AcceptedFrontier responds to a AcceptedFrontier message with this // engine's current accepted frontier. AcceptedFrontier(validatorID ids.ShortID, requestID uint32, containerIDs ids.Set) }
FrontierSender defines how a consensus engine sends frontier messages to other validators
type HTTPHandler ¶
type HTTPHandler struct { LockOptions LockOption Handler http.Handler }
HTTPHandler ...
type Handler ¶
type Handler interface { ExternalHandler InternalHandler }
Handler defines the functions that are acted on the node
type InternalHandler ¶
type InternalHandler interface { // Startup this engine. Startup() // Shutdown this engine. Shutdown() // Notify this engine that the vm has sent a message to it. Notify(Message) }
InternalHandler defines how this consensus engine reacts to messages from other components of this validator
type LockOption ¶
type LockOption uint32
LockOption allows the vm to specify their lock option based on their endpoint
type Message ¶
type Message uint32
Message is an enum of the message types that vms can send to consensus
type QueryHandler ¶
type QueryHandler interface { // Notify this engine that the specified validator queried it about the // specified container. That is, the validator would like to know whether // this engine prefers the specified container. If the ancestry of the // container is incomplete, or the container is unknown, request the missing // data. Once complete, sends this validator the current preferences. PullQuery(validatorID ids.ShortID, requestID uint32, containerID ids.ID) // Notify this engine that the specified validator queried it about the // specified container. That is, the validator would like to know whether // this engine prefers the specified container. If the ancestry of the // container is incomplete, request it. Once complete, sends this validator // the current preferences. PushQuery(validatorID ids.ShortID, requestID uint32, containerID ids.ID, container []byte) // Notify this engine of the specified validators preferences. Chits(validatorID ids.ShortID, requestID uint32, containerIDs ids.Set) // Notify this engine that a query it issued has failed. QueryFailed(validatorID ids.ShortID, requestID uint32) }
QueryHandler defines how a consensus engine reacts to query messages from other validators
type QuerySender ¶
type QuerySender interface { // Request from the specified validators their preferred frontier, given the // existence of the specified container. // This is the same as PullQuery, except that this message includes not only // the ID of the container but also its body. PushQuery(validatorIDs ids.ShortSet, requestID uint32, containerID ids.ID, container []byte) // Request from the specified validators their preferred frontier, given the // existence of the specified container. PullQuery(validatorIDs ids.ShortSet, requestID uint32, containerID ids.ID) // Chits sends chits to the specified validator Chits(validatorID ids.ShortID, requestID uint32, votes ids.Set) }
QuerySender defines how a consensus engine sends query messages to other validators
type Sender ¶
type Sender interface { FrontierSender AcceptedSender FetchSender QuerySender }
Sender defines how a consensus engine sends messages and requests to other validators
type SenderTest ¶
type SenderTest struct { T *testing.T CantGetAcceptedFrontier, CantAcceptedFrontier, CantGetAccepted, CantAccepted, CantGet, CantPut, CantPullQuery, CantPushQuery, CantChits bool GetAcceptedFrontierF func(ids.ShortSet, uint32) AcceptedFrontierF func(ids.ShortID, uint32, ids.Set) GetAcceptedF func(ids.ShortSet, uint32, ids.Set) AcceptedF func(ids.ShortID, uint32, ids.Set) GetF func(ids.ShortID, uint32, ids.ID) PutF func(ids.ShortID, uint32, ids.ID, []byte) PushQueryF func(ids.ShortSet, uint32, ids.ID, []byte) PullQueryF func(ids.ShortSet, uint32, ids.ID) ChitsF func(ids.ShortID, uint32, ids.Set) }
SenderTest is a test sender
func (*SenderTest) Accepted ¶
Accepted calls AcceptedF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.
func (*SenderTest) AcceptedFrontier ¶
func (s *SenderTest) AcceptedFrontier(validatorID ids.ShortID, requestID uint32, containerIDs ids.Set)
AcceptedFrontier calls AcceptedFrontierF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.
func (*SenderTest) Chits ¶
Chits calls ChitsF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.
func (*SenderTest) Default ¶
func (s *SenderTest) Default(cant bool)
Default set the default callable value to [cant]
func (*SenderTest) Get ¶
Get calls GetF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.
func (*SenderTest) GetAccepted ¶
GetAccepted calls GetAcceptedF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.
func (*SenderTest) GetAcceptedFrontier ¶
func (s *SenderTest) GetAcceptedFrontier(validatorIDs ids.ShortSet, requestID uint32)
GetAcceptedFrontier calls GetAcceptedFrontierF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.
func (*SenderTest) PullQuery ¶
PullQuery calls PullQueryF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.
type StaticVM ¶
type StaticVM interface { // Creates the HTTP handlers for custom VM network calls. // // This exposes handlers that the outside world can use to communicate with // a static reference to the VM. Each handler has the path: // [Address of node]/ext/VM/[VM ID]/[extension] // // Returns a mapping from [extension]s to HTTP handlers. // // Each extension can specify how locking is managed for convenience. // // For example, it might make sense to have an extension for creating // genesis bytes this VM can interpret. CreateStaticHandlers() map[string]*HTTPHandler }
StaticVM describes the functionality that allows a user to interact with a VM statically.
type VM ¶
type VM interface { // Initialize this VM. // [ctx]: Metadata about this VM. // [ctx.networkID]: The ID of the network this VM's chain is running // on. // [ctx.chainID]: The unique ID of the chain this VM is running on. // [ctx.Log]: Used to log messages // [ctx.NodeID]: The unique staker ID of this node. // [ctx.Lock]: A Read/Write lock shared by this VM and the consensus // engine that manages this VM. The write lock is held // whenever code in the consensus engine calls the VM. // [db]: The database this VM will persist data to. // [genesisBytes]: The byte-encoding of the genesis information of this // VM. The VM uses it to initialize its state. For // example, if this VM were an account-based payments // system, `genesisBytes` would probably contain a genesis // transaction that gives coins to some accounts, and this // transaction would be in the genesis block. // [toEngine]: The channel used to send messages to the consensus engine. // [fxs]: Feature extensions that attach to this VM. Initialize( ctx *snow.Context, db database.Database, genesisBytes []byte, toEngine chan<- Message, fxs []*Fx, ) error // Shutdown is called when the node is shutting down. Shutdown() // Creates the HTTP handlers for custom chain network calls. // // This exposes handlers that the outside world can use to communicate with // the chain. Each handler has the path: // [Address of node]/ext/bc/[chain ID]/[extension] // // Returns a mapping from [extension]s to HTTP handlers. // // Each extension can specify how locking is managed for convenience. // // For example, if this VM implements an account-based payments system, // it have an extension called `accounts`, where clients could get // information about their accounts. CreateHandlers() map[string]*HTTPHandler }
VM describes the interface that all consensus VMs must implement
type VMTest ¶
type VMTest struct { T *testing.T CantInitialize, CantShutdown, CantCreateHandlers, CantCreateStaticHandlers bool InitializeF func(*snow.Context, database.Database, []byte, chan<- Message, []*Fx) error ShutdownF func() CreateHandlersF func() map[string]*HTTPHandler CreateStaticHandlersF func() map[string]*HTTPHandler }
VMTest is a test vm
func (*VMTest) CreateHandlers ¶
func (vm *VMTest) CreateHandlers() map[string]*HTTPHandler
CreateHandlers ...
func (*VMTest) CreateStaticHandlers ¶
func (vm *VMTest) CreateStaticHandlers() map[string]*HTTPHandler
CreateStaticHandlers ...