platformvm

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2020 License: BSD-3-Clause Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Delta is the synchrony bound used for safe decision making
	Delta = 10 * time.Second

	// BatchSize is the number of decision transaction to place into a block
	BatchSize = 30

	// NumberOfShares is the number of shares that a delegator is
	// rewarded
	NumberOfShares = 1000000

	// InflationRate is the inflation rate from staking
	// TODO: make inflation rate non-zero
	InflationRate = 1.00

	// MinimumStakingDuration is the shortest amount of time a staker can bond
	// their funds for.
	MinimumStakingDuration = 24 * time.Hour

	// MaximumStakingDuration is the longest amount of time a staker can bond
	// their funds for.
	MaximumStakingDuration = 365 * 24 * time.Hour
)

Variables

View Source
var Codec codec.Codec

Codec does serialization and deserialization

View Source
var (
	ID = ids.NewID([32]byte{'p', 'l', 'a', 't', 'f', 'o', 'r', 'm', 'v', 'm'})
)

ID of the platform VM

Functions

This section is empty.

Types

type APIBlockchain

type APIBlockchain struct {
	// Blockchain's ID
	ID ids.ID `json:"id"`

	// Blockchain's (non-unique) human-readable name
	Name string `json:"name"`

	// Subnet that validates the blockchain
	SubnetID ids.ID `json:"subnetID"`

	// Virtual Machine the blockchain runs
	VMID ids.ID `json:"vmID"`
}

APIBlockchain is the representation of a blockchain used in API calls

type APIChain

type APIChain struct {
	GenesisData formatting.CB58 `json:"genesisData"`
	VMID        ids.ID          `json:"vmID"`
	FxIDs       []ids.ID        `json:"fxIDs"`
	Name        string          `json:"name"`
	SubnetID    ids.ID          `json:"subnetID"`
}

APIChain defines a chain that exists at the network's genesis. [GenesisData] is the initial state of the chain. [VMID] is the ID of the VM this chain runs. [FxIDs] are the IDs of the Fxs the chain supports. [Name] is a human-readable, non-unique name for the chain. [SubnetID] is the ID of the subnet that validates the chain

type APIPrimaryValidator added in v0.7.0

type APIPrimaryValidator struct {
	APIValidator

	RewardAddress     string      `json:"rewardAddress"`
	DelegationFeeRate json.Uint32 `json:"delegationFeeRate"`
}

APIPrimaryValidator is a validator of the primary network

type APISubnet

type APISubnet struct {
	// ID of the subnet
	ID ids.ID `json:"id"`

	// Each element of [ControlKeys] the address of a public key.
	// A transaction to add a validator to this subnet requires
	// signatures from [Threshold] of these keys to be valid.
	ControlKeys []string    `json:"controlKeys"`
	Threshold   json.Uint32 `json:"threshold"`
}

APISubnet is a representation of a subnet used in API calls

type APIUTXO added in v0.6.1

type APIUTXO struct {
	Amount  json.Uint64 `json:"amount"`
	Address string      `json:"address"`
}

APIUTXO is a UTXO on the Platform Chain that exists at the chain's genesis.

type APIValidator

type APIValidator struct {
	StartTime   json.Uint64  `json:"startTime"`
	EndTime     json.Uint64  `json:"endTime"`
	Weight      *json.Uint64 `json:"weight,omitempty"`
	StakeAmount *json.Uint64 `json:"stakeAmount,omitempty"`
	Address     string       `json:"address,omitempty"`
	ID          ids.ShortID  `json:"id"`
}

APIValidator is a validator. [Amount] is the amount of tokens being staked. [Endtime] is the Unix time repr. of when they are done staking ID is the node ID of the staker [Address] is the address where the staked $AVAX (and, if applicable, reward) is sent when this staker is done staking.

type Abort

type Abort struct {
	DoubleDecisionBlock `serialize:"true"`
}

Abort being accepted results in the proposal of its parent (which must be a proposal block) being rejected.

func (*Abort) Verify

func (a *Abort) Verify() error

Verify this block performs a valid state transition.

The parent block must be a proposal

This function also sets onAcceptDB database if the verification passes.

type AddDelegatorArgs added in v0.7.0

type AddDelegatorArgs struct {
	FormattedAPIValidator
	api.UserPass
	RewardAddress string `json:"rewardAddress"`
}

AddDelegatorArgs are the arguments to AddDelegator

type AddSubnetValidatorArgs added in v0.7.0

type AddSubnetValidatorArgs struct {
	FormattedAPIValidator
	api.UserPass
	// ID of subnet to validate
	SubnetID string `json:"subnetID"`
}

AddSubnetValidatorArgs are the arguments to AddSubnetValidator

type AddValidatorArgs added in v0.7.0

type AddValidatorArgs struct {
	FormattedAPIPrimaryValidator

	api.UserPass
}

AddValidatorArgs are the arguments to AddValidator

type AtomicBlock

type AtomicBlock struct {
	CommonDecisionBlock `serialize:"true"`

	Tx Tx `serialize:"true" json:"tx"`
	// contains filtered or unexported fields
}

AtomicBlock being accepted results in the transaction contained in the block to be accepted and committed to the chain.

func (*AtomicBlock) Accept

func (ab *AtomicBlock) Accept() error

Accept implements the snowman.Block interface

func (*AtomicBlock) Verify

func (ab *AtomicBlock) Verify() error

Verify this block performs a valid state transition.

The parent block must be a proposal

This function also sets onAcceptDB database if the verification passes.

type BaseTx added in v0.6.1

type BaseTx struct {
	avax.BaseTx `serialize:"true" json:"inputs"`
	// contains filtered or unexported fields
}

BaseTx contains fields common to many transaction types. It should be embedded in transaction implementations.

func (*BaseTx) Verify added in v0.6.1

func (tx *BaseTx) Verify(ctx *snow.Context, c codec.Codec) error

Verify returns nil iff this tx is well formed

type Block

type Block interface {
	snowman.Block

	// This block's height
	Height() uint64
	// contains filtered or unexported methods
}

Block is the common interface that all staking blocks must have

type BuildGenesisArgs

type BuildGenesisArgs struct {
	AvaxAssetID ids.ID                         `json:"avaxAssetID"`
	NetworkID   json.Uint32                    `json:"address"`
	UTXOs       []APIUTXO                      `json:"utxos"`
	Validators  []FormattedAPIPrimaryValidator `json:"primaryNetworkValidators"`
	Chains      []APIChain                     `json:"chains"`
	Time        json.Uint64                    `json:"time"`
	Message     string                         `json:"message"`
}

BuildGenesisArgs are the arguments used to create the genesis data of the Platform Chain. [NetworkID] is the ID of the network [UTXOs] are the UTXOs on the Platform Chain that exist at genesis. [Validators] are the validators of the primary network at genesis. [Chains] are the chains that exist at genesis. [Time] is the Platform Chain's time at network genesis.

type BuildGenesisReply

type BuildGenesisReply struct {
	Bytes formatting.CB58 `json:"bytes"`
}

BuildGenesisReply is the reply from BuildGenesis

type Commit

type Commit struct {
	DoubleDecisionBlock `serialize:"true"`
}

Commit being accepted results in the proposal of its parent (which must be a proposal block) being enacted.

func (*Commit) Verify

func (c *Commit) Verify() error

Verify this block performs a valid state transition.

The parent block must either be a proposal

This function also sets the onCommit databases if the verification passes.

type CommonBlock

type CommonBlock struct {
	*core.Block `serialize:"true"`
	// contains filtered or unexported fields
}

CommonBlock contains the fields common to all blocks of the Platform Chain

func (*CommonBlock) Parent

func (cb *CommonBlock) Parent() snowman.Block

Parent returns this block's parent

func (*CommonBlock) Reject

func (cb *CommonBlock) Reject() error

Reject implements the snowman.Block interface

type CommonDecisionBlock

type CommonDecisionBlock struct {
	CommonBlock `serialize:"true"`
	// contains filtered or unexported fields
}

CommonDecisionBlock contains the fields and methods common to all decision blocks

type CreateBlockchainArgs

type CreateBlockchainArgs struct {
	api.UserPass
	// ID of Subnet that validates the new blockchain
	SubnetID ids.ID `json:"subnetID"`
	// ID of the VM the new blockchain is running
	VMID string `json:"vmID"`
	// IDs of the FXs the VM is running
	FxIDs []string `json:"fxIDs"`
	// Human-readable name for the new blockchain, not necessarily unique
	Name string `json:"name"`
	// Genesis state of the blockchain being created
	GenesisData formatting.CB58 `json:"genesisData"`
}

CreateBlockchainArgs is the arguments for calling CreateBlockchain

type CreateSubnetArgs

type CreateSubnetArgs struct {
	// The ID member of APISubnet is ignored
	APISubnet
	api.UserPass
}

CreateSubnetArgs are the arguments to CreateSubnet

type DoubleDecisionBlock added in v0.5.0

type DoubleDecisionBlock struct {
	CommonDecisionBlock `serialize:"true"`
}

DoubleDecisionBlock contains the accept for a pair of blocks

func (*DoubleDecisionBlock) Accept added in v0.5.0

func (ddb *DoubleDecisionBlock) Accept() error

Accept implements the snowman.Block interface

type EventHeap

type EventHeap struct {
	SortByStartTime bool  `serialize:"true"`
	Txs             []*Tx `serialize:"true"`
}

EventHeap is a collection of timedTxs where elements are ordered by either their startTime or their endTime. If SortByStartTime == true, the first element of [Txs] is the tx in the heap with the earliest startTime. Otherwise the first element is the tx with earliest endTime. The default value of this struct will order transactions by endTime. This struct implements the heap interface. Transactions must be syntactically verified before adding to EventHeap to ensure that EventHeap can always by marshalled.

func (*EventHeap) Add

func (h *EventHeap) Add(tx *Tx)

Add ...

func (*EventHeap) Bytes

func (h *EventHeap) Bytes() ([]byte, error)

Bytes returns the byte representation of this heap

func (*EventHeap) Len

func (h *EventHeap) Len() int

func (*EventHeap) Less

func (h *EventHeap) Less(i, j int) bool

func (*EventHeap) Peek

func (h *EventHeap) Peek() *Tx

Peek ...

func (*EventHeap) Pop

func (h *EventHeap) Pop() interface{}

Pop implements the heap interface

func (*EventHeap) Push

func (h *EventHeap) Push(x interface{})

Push implements the heap interface

func (*EventHeap) Remove

func (h *EventHeap) Remove() *Tx

Remove ...

func (*EventHeap) Swap

func (h *EventHeap) Swap(i, j int)

func (*EventHeap) Timestamp

func (h *EventHeap) Timestamp() time.Time

Timestamp returns the timestamp on the top transaction on the heap

type ExportAVAXArgs added in v0.6.1

type ExportAVAXArgs struct {
	api.UserPass

	// Amount of AVAX to send
	Amount json.Uint64 `json:"amount"`

	// ID of the address that will receive the AVAX. This address includes the
	// chainID, which is used to determine what the destination chain is.
	To string `json:"to"`
}

ExportAVAXArgs are the arguments to ExportAVAX

type ExportKeyArgs added in v0.5.3

type ExportKeyArgs struct {
	api.UserPass
	Address string `json:"address"`
}

ExportKeyArgs are arguments for ExportKey

type ExportKeyReply added in v0.5.3

type ExportKeyReply struct {
	// The decrypted PrivateKey for the Address provided in the arguments
	PrivateKey string `json:"privateKey"`
}

ExportKeyReply is the response for ExportKey

type Factory

type Factory struct {
	ChainManager   chains.Manager
	Validators     validators.Manager
	StakingEnabled bool
	Fee            uint64
	MinStake       uint64
}

Factory can create new instances of the Platform Chain

func (*Factory) New

func (f *Factory) New(*snow.Context) (interface{}, error)

New returns a new instance of the Platform Chain

type FormattedAPIPrimaryValidator added in v0.7.0

type FormattedAPIPrimaryValidator struct {
	FormattedAPIValidator

	RewardAddress string `json:"rewardAddress"`

	// Delegation fee rate as a percentage. Must be in [0,100].
	DelegationFeeRate json.Float32 `json:"delegationFeeRate"`
}

FormattedAPIPrimaryValidator is a formatted validator of the primary network

type FormattedAPIValidator added in v0.5.3

type FormattedAPIValidator struct {
	StartTime   json.Uint64  `json:"startTime"`
	EndTime     json.Uint64  `json:"endTime"`
	Weight      *json.Uint64 `json:"weight,omitempty"`
	StakeAmount *json.Uint64 `json:"stakeAmount,omitempty"`
	ID          string       `json:"nodeID"`
}

FormattedAPIValidator allows for a formatted address

type Fx added in v0.6.1

type Fx interface {
	// Initialize this feature extension to be running under this VM. Should
	// return an error if the VM is incompatible.
	Initialize(vm interface{}) error

	// Notify this Fx that the VM is in bootstrapping
	Bootstrapping() error

	// Notify this Fx that the VM is bootstrapped
	Bootstrapped() error

	// VerifyTransfer verifies that the specified transaction can spend the
	// provided utxo with no restrictions on the destination. If the transaction
	// can't spend the output based on the input and credential, a non-nil error
	// should be returned.
	VerifyTransfer(tx, in, cred, utxo interface{}) error

	// VerifyPermission returns nil iff [cred] proves that [controlGroup]
	// assents to [tx]
	VerifyPermission(tx, in, cred, controlGroup interface{}) error

	// CreateOutput creates a new output with the provided control group worth
	// the specified amount
	CreateOutput(amount uint64, controlGroup interface{}) (interface{}, error)
}

Fx is the interface a feature extension must implement to support the Platform Chain.

type Genesis

type Genesis struct {
	UTXOs      []*avax.UTXO `serialize:"true"`
	Validators []*Tx        `serialize:"true"`
	Chains     []*Tx        `serialize:"true"`
	Timestamp  uint64       `serialize:"true"`
	Message    string       `serialize:"true"`
}

Genesis represents a genesis state of the platform chain

func (*Genesis) Initialize

func (g *Genesis) Initialize() error

Initialize ...

type GetBalanceArgs added in v0.6.1

type GetBalanceArgs struct {
	// Address to get the balance of
	Address string `json:"address"`
}

GetBalanceArgs ...

type GetBalanceResponse added in v0.6.1

type GetBalanceResponse struct {
	// Balance, in nAVAX, of the address
	Balance json.Uint64    `json:"balance"`
	UTXOIDs []*avax.UTXOID `json:"utxoIDs"`
}

GetBalanceResponse ...

type GetBlockchainStatusArgs

type GetBlockchainStatusArgs struct {
	BlockchainID string `json:"blockchainID"`
}

GetBlockchainStatusArgs is the arguments for calling GetBlockchainStatus [BlockchainID] is the ID of or an alias of the blockchain to get the status of.

type GetBlockchainStatusReply

type GetBlockchainStatusReply struct {
	Status Status `json:"status"`
}

GetBlockchainStatusReply is the reply from calling GetBlockchainStatus Status is the blockchain's status.

type GetBlockchainsResponse

type GetBlockchainsResponse struct {
	// blockchains that exist
	Blockchains []APIBlockchain `json:"blockchains"`
}

GetBlockchainsResponse is the response from a call to GetBlockchains

type GetCurrentValidatorsArgs

type GetCurrentValidatorsArgs struct {
	// Subnet we're listing the validators of
	// If omitted, defaults to primary network
	SubnetID ids.ID `json:"subnetID"`
}

GetCurrentValidatorsArgs are the arguments for calling GetCurrentValidators

type GetCurrentValidatorsReply

type GetCurrentValidatorsReply struct {
	Validators []FormattedAPIValidator `json:"validators"`
}

GetCurrentValidatorsReply are the results from calling GetCurrentValidators

type GetHeightResponse added in v0.6.1

type GetHeightResponse struct {
	Height json.Uint64 `json:"height"`
}

GetHeightResponse ...

type GetPendingValidatorsArgs

type GetPendingValidatorsArgs struct {
	// Subnet we're getting the pending validators of
	// If omitted, defaults to primary network
	SubnetID ids.ID `json:"subnetID"`
}

GetPendingValidatorsArgs are the arguments for calling GetPendingValidators

type GetPendingValidatorsReply

type GetPendingValidatorsReply struct {
	Validators []FormattedAPIValidator `json:"validators"`
}

GetPendingValidatorsReply are the results from calling GetPendingValidators

type GetStakingAssetIDArgs added in v0.6.1

type GetStakingAssetIDArgs struct {
	SubnetID ids.ID `json:"subnetID"`
}

GetStakingAssetIDArgs are the arguments to GetStakingAssetID

type GetStakingAssetIDResponse added in v0.6.1

type GetStakingAssetIDResponse struct {
	AssetID ids.ID `json:"assetID"`
}

GetStakingAssetIDResponse is the response from calling GetStakingAssetID

type GetSubnetsArgs

type GetSubnetsArgs struct {
	// IDs of the subnets to retrieve information about
	// If omitted, gets all subnets
	IDs []ids.ID `json:"ids"`
}

GetSubnetsArgs are the arguments to GetSubnet

type GetSubnetsResponse

type GetSubnetsResponse struct {
	// Each element is a subnet that exists
	// Null if there are no subnets other than the primary network
	Subnets []APISubnet `json:"subnets"`
}

GetSubnetsResponse is the response from calling GetSubnets

type GetTxArgs added in v0.6.1

type GetTxArgs struct {
	TxID ids.ID `json:"txID"`
}

GetTxArgs ...

type GetTxResponse added in v0.6.1

type GetTxResponse struct {
	// Raw byte representation of the transaction
	Tx formatting.CB58 `json:"tx"`
}

GetTxResponse ...

type GetTxStatusArgs added in v0.6.1

type GetTxStatusArgs struct {
	TxID ids.ID `json:"txID"`
}

GetTxStatusArgs ...

type GetUTXOsArgs added in v0.6.1

type GetUTXOsArgs struct {
	Addresses  []string    `json:"addresses"`
	Limit      json.Uint32 `json:"limit"`
	StartIndex Index       `json:"startIndex"`
}

GetUTXOsArgs are arguments for passing into GetUTXOs. Gets the UTXOs that reference at least one address in [Addresses]. Returns at most [limit] addresses. If [limit] == 0 or > [maxUTXOsToFetch], fetches up to [maxUTXOsToFetch]. [StartIndex] defines where to start fetching UTXOs (for pagination.) UTXOs fetched are from addresses equal to or greater than [StartIndex.Address] For address [StartIndex.Address], only UTXOs with IDs greater than [StartIndex.UTXO] will be returned. If [StartIndex] is omitted, gets all UTXOs. If GetUTXOs is called multiple times, with our without [StartIndex], it is not guaranteed that returned UTXOs are unique. That is, the same UTXO may appear in the response of multiple calls.

type GetUTXOsResponse added in v0.6.1

type GetUTXOsResponse struct {
	// Number of UTXOs returned
	NumFetched json.Uint64 `json:"numFetched"`
	// The UTXOs
	UTXOs []formatting.CB58 `json:"utxos"`
	// The last UTXO that was returned, and the address it corresponds to.
	// Used for pagination. To get the rest of the UTXOs, call GetUTXOs
	// again and set [StartIndex] to this value.
	EndIndex Index `json:"endIndex"`
}

GetUTXOsResponse defines the GetUTXOs replies returned from the API

type ImportAVAXArgs added in v0.6.1

type ImportAVAXArgs struct {
	api.UserPass

	// Chain the funds are coming from
	SourceChain string `json:"sourceChain"`

	// The address that will receive the imported funds
	To string `json:"to"`
}

ImportAVAXArgs are the arguments to ImportAVAX

type ImportKeyArgs added in v0.5.3

type ImportKeyArgs struct {
	api.UserPass
	PrivateKey string `json:"privateKey"`
}

ImportKeyArgs are arguments for ImportKey

type Index added in v0.6.1

type Index struct {
	Address string `json:"address"` // The address as a string
	UTXO    string `json:"utxo"`    // The UTXO ID as a string
}

Index is an address and an associated UTXO. Marks a starting or stopping point when fetching UTXOs. Used for pagination.

type IssueTxArgs

type IssueTxArgs struct {
	// Raw byte representation of the transaction
	Tx formatting.CB58 `json:"tx"`
}

IssueTxArgs ...

type IssueTxResponse

type IssueTxResponse struct {
	TxID ids.ID `json:"txID"`
}

IssueTxResponse ...

type Owned added in v0.6.1

type Owned interface {
	Owners() interface{}
}

Owned ...

type ProposalBlock

type ProposalBlock struct {
	CommonBlock `serialize:"true"`

	Tx Tx `serialize:"true" json:"tx"`
	// contains filtered or unexported fields
}

ProposalBlock is a proposal to change the chain's state. A proposal may be to:

  1. Advance the chain's timestamp (*AdvanceTimeTx)
  2. Remove a staker from the staker set (*RewardStakerTx)
  3. Add a new staker to the set of pending (future) stakers (*AddStakerTx)

The proposal will be enacted (change the chain's state) if the proposal block is accepted and followed by an accepted Commit block

func (*ProposalBlock) Accept added in v0.5.0

func (pb *ProposalBlock) Accept() error

Accept implements the snowman.Block interface

func (*ProposalBlock) Options

func (pb *ProposalBlock) Options() ([2]snowman.Block, error)

Options returns the possible children of this block in preferential order.

func (*ProposalBlock) Verify

func (pb *ProposalBlock) Verify() error

Verify this block is valid.

The parent block must either be a Commit or an Abort block.

If this block is valid, this function also sets pas.onCommit and pas.onAbort.

type SampleValidatorsArgs

type SampleValidatorsArgs struct {
	// Number of validators in the sample
	Size json.Uint16 `json:"size"`

	// ID of subnet to sample validators from
	// If omitted, defaults to the primary network
	SubnetID ids.ID `json:"subnetID"`
}

SampleValidatorsArgs are the arguments for calling SampleValidators

type SampleValidatorsReply

type SampleValidatorsReply struct {
	Validators []string `json:"validators"`
}

SampleValidatorsReply are the results from calling Sample

type Service

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

Service defines the API calls that can be made to the platform chain

func (*Service) AddDelegator added in v0.7.0

func (service *Service) AddDelegator(_ *http.Request, args *AddDelegatorArgs, reply *api.JsonTxID) error

AddDelegator creates and signs and issues a transaction to add a delegator to the primary network

func (*Service) AddSubnetValidator added in v0.7.0

func (service *Service) AddSubnetValidator(_ *http.Request, args *AddSubnetValidatorArgs, response *api.JsonTxID) error

AddSubnetValidator creates and signs and issues a transaction to add a validator to a subnet other than the primary network

func (*Service) AddValidator added in v0.7.0

func (service *Service) AddValidator(_ *http.Request, args *AddValidatorArgs, reply *api.JsonTxID) error

AddValidator creates and signs and issues a transaction to add a validator to the primary network

func (*Service) CreateAddress added in v0.6.1

func (service *Service) CreateAddress(_ *http.Request, args *api.UserPass, response *api.JsonAddress) error

CreateAddress creates an address controlled by [args.Username] Returns the newly created address

func (*Service) CreateBlockchain

func (service *Service) CreateBlockchain(_ *http.Request, args *CreateBlockchainArgs, response *api.JsonTxID) error

CreateBlockchain issues a transaction to create a new blockchain

func (*Service) CreateSubnet

func (service *Service) CreateSubnet(_ *http.Request, args *CreateSubnetArgs, response *api.JsonTxID) error

CreateSubnet creates and signs and issues a transaction to create a new subnet

func (*Service) ExportAVAX added in v0.6.1

func (service *Service) ExportAVAX(_ *http.Request, args *ExportAVAXArgs, response *api.JsonTxID) error

ExportAVAX exports AVAX from the P-Chain to the X-Chain It must be imported on the X-Chain to complete the transfer

func (*Service) ExportKey added in v0.5.3

func (service *Service) ExportKey(r *http.Request, args *ExportKeyArgs, reply *ExportKeyReply) error

ExportKey returns a private key from the provided user

func (*Service) GetBalance added in v0.6.1

func (service *Service) GetBalance(_ *http.Request, args *GetBalanceArgs, response *GetBalanceResponse) error

GetBalance gets the balance of an address

func (*Service) GetBlockchainStatus

func (service *Service) GetBlockchainStatus(_ *http.Request, args *GetBlockchainStatusArgs, reply *GetBlockchainStatusReply) error

GetBlockchainStatus gets the status of a blockchain with the ID [args.BlockchainID].

func (*Service) GetBlockchains

func (service *Service) GetBlockchains(_ *http.Request, args *struct{}, response *GetBlockchainsResponse) error

GetBlockchains returns all of the blockchains that exist

func (*Service) GetCurrentValidators

func (service *Service) GetCurrentValidators(_ *http.Request, args *GetCurrentValidatorsArgs, reply *GetCurrentValidatorsReply) error

GetCurrentValidators returns the list of current validators

func (*Service) GetHeight added in v0.6.1

func (service *Service) GetHeight(r *http.Request, args *struct{}, response *GetHeightResponse) error

GetHeight returns the height of the last accepted block

func (*Service) GetPendingValidators

func (service *Service) GetPendingValidators(_ *http.Request, args *GetPendingValidatorsArgs, reply *GetPendingValidatorsReply) error

GetPendingValidators returns the list of pending validators

func (*Service) GetStakingAssetID added in v0.6.1

func (service *Service) GetStakingAssetID(_ *http.Request, args *GetStakingAssetIDArgs, response *GetStakingAssetIDResponse) error

GetStakingAssetID returns the assetID of the token used to stake on the provided subnet

func (*Service) GetSubnets

func (service *Service) GetSubnets(_ *http.Request, args *GetSubnetsArgs, response *GetSubnetsResponse) error

GetSubnets returns the subnets whose ID are in [args.IDs] The response will include the primary network

func (*Service) GetTx added in v0.6.1

func (service *Service) GetTx(_ *http.Request, args *GetTxArgs, response *GetTxResponse) error

GetTx gets a tx

func (*Service) GetTxStatus added in v0.6.1

func (service *Service) GetTxStatus(_ *http.Request, args *GetTxStatusArgs, response *Status) error

GetTxStatus gets a tx's status

func (*Service) GetUTXOs added in v0.6.1

func (service *Service) GetUTXOs(_ *http.Request, args *GetUTXOsArgs, response *GetUTXOsResponse) error

GetUTXOs returns the UTXOs controlled by the given addresses

func (*Service) ImportAVAX added in v0.6.1

func (service *Service) ImportAVAX(_ *http.Request, args *ImportAVAXArgs, response *api.JsonTxID) error

ImportAVAX issues a transaction to import AVAX from the X-chain. The AVAX must have already been exported from the X-Chain.

func (*Service) ImportKey added in v0.5.3

func (service *Service) ImportKey(r *http.Request, args *ImportKeyArgs, reply *api.JsonAddress) error

ImportKey adds a private key to the provided user

func (*Service) IssueTx

func (service *Service) IssueTx(_ *http.Request, args *IssueTxArgs, response *IssueTxResponse) error

IssueTx issues a tx

func (*Service) ListAddresses added in v0.6.1

func (service *Service) ListAddresses(_ *http.Request, args *api.UserPass, response *api.JsonAddresses) error

ListAddresses returns the addresses controlled by [args.Username]

func (*Service) SampleValidators

func (service *Service) SampleValidators(_ *http.Request, args *SampleValidatorsArgs, reply *SampleValidatorsReply) error

SampleValidators returns a sampling of the list of current validators

func (*Service) ValidatedBy

func (service *Service) ValidatedBy(_ *http.Request, args *ValidatedByArgs, response *ValidatedByResponse) error

ValidatedBy returns the ID of the Subnet that validates [args.BlockchainID]

func (*Service) Validates

func (service *Service) Validates(_ *http.Request, args *ValidatesArgs, response *ValidatesResponse) error

Validates returns the IDs of the blockchains validated by [args.SubnetID]

type SingleDecisionBlock added in v0.5.0

type SingleDecisionBlock struct {
	CommonDecisionBlock `serialize:"true"`
}

SingleDecisionBlock contains the accept for standalone decision blocks

func (*SingleDecisionBlock) Accept added in v0.5.0

func (sdb *SingleDecisionBlock) Accept() error

Accept implements the snowman.Block interface

type StakeableLockIn added in v0.6.1

type StakeableLockIn struct {
	Locktime            uint64 `serialize:"true" json:"locktime"`
	avax.TransferableIn `serialize:"true"`
}

StakeableLockIn ...

func (*StakeableLockIn) Verify added in v0.6.1

func (s *StakeableLockIn) Verify() error

Verify ...

type StakeableLockOut added in v0.6.1

type StakeableLockOut struct {
	Locktime             uint64 `serialize:"true" json:"locktime"`
	avax.TransferableOut `serialize:"true"`
}

StakeableLockOut ...

func (*StakeableLockOut) Verify added in v0.6.1

func (s *StakeableLockOut) Verify() error

Verify ...

type StandardBlock

type StandardBlock struct {
	SingleDecisionBlock `serialize:"true"`

	Txs []*Tx `serialize:"true" json:"txs"`
}

StandardBlock being accepted results in the transactions contained in the block to be accepted and committed to the chain.

func (*StandardBlock) Verify

func (sb *StandardBlock) Verify() error

Verify this block performs a valid state transition.

The parent block must be a proposal

This function also sets onAcceptDB database if the verification passes.

type StaticService

type StaticService struct{}

StaticService defines the static API methods exposed by the platform VM

func (*StaticService) BuildGenesis

func (ss *StaticService) BuildGenesis(_ *http.Request, args *BuildGenesisArgs, reply *BuildGenesisReply) error

BuildGenesis build the genesis state of the Platform Chain (and thereby the Avalanche network.)

type Status

type Status uint32

Status ...

const (
	Unknown Status = iota
	Preferred
	Created
	Validating
	Committed
	Aborted
	Processing
	Dropped
)

List of possible status values Unknown Zero value, means the status is not known Preferred means the operation is known and preferred, but hasn't been decided yet Created means the operation occurred, but isn't managed locally Validating means the operation was accepted and is managed locally

func (Status) MarshalJSON

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

MarshalJSON ...

func (Status) String

func (s Status) String() string

func (*Status) UnmarshalJSON

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

UnmarshalJSON ...

func (Status) Valid

func (s Status) Valid() error

Valid returns nil if the status is a valid status.

type Subnet

type Subnet interface {
	// ID returns this subnet's ID
	ID() ids.ID

	// Validators returns the validators that compose this subnet
	Validators() []validators.Validator
}

A Subnet is a set of validators that are validating a set of blockchains Each blockchain is validated by one subnet; one subnet may validate many blockchains

type SubnetValidator

type SubnetValidator struct {
	Validator `serialize:"true"`

	// ID of the subnet this validator is validating
	Subnet ids.ID `serialize:"true" json:"subnet"`
}

SubnetValidator validates a subnet on the Avalanche network.

func (*SubnetValidator) SubnetID

func (v *SubnetValidator) SubnetID() ids.ID

SubnetID is the ID of the subnet this validator is validating

func (*SubnetValidator) Verify added in v0.6.1

func (v *SubnetValidator) Verify() error

Verify this validator is valid

type TimedTx

type TimedTx interface {
	ID() ids.ID
	StartTime() time.Time
	EndTime() time.Time
	Bytes() []byte
}

TimedTx ...

type Tx added in v0.6.1

type Tx struct {
	// The body of this transaction
	UnsignedTx `serialize:"true" json:"unsignedTx"`

	// The credentials of this transaction
	Creds []verify.Verifiable `serialize:"true" json:"credentials"`
}

Tx is a signed transaction

func (*Tx) Sign added in v0.6.1

func (tx *Tx) Sign(c codec.Codec, signers [][]*crypto.PrivateKeySECP256K1R) error

Sign this transaction with the provided signers

type TxError added in v0.5.4

type TxError interface {
	error
	Temporary() bool
}

TxError provides the ability for errors to be distinguished as permenant or temporary

type UnsignedAddDelegatorTx added in v0.7.0

type UnsignedAddDelegatorTx struct {
	// Metadata, inputs and outputs
	BaseTx `serialize:"true"`
	// Describes the delegatee
	Validator Validator `serialize:"true" json:"validator"`
	// Where to send staked tokens when done validating
	Stake []*avax.TransferableOutput `serialize:"true" json:"stake"`
	// Where to send staking rewards when done validating
	RewardsOwner verify.Verifiable `serialize:"true" json:"rewardsOwner"`
}

UnsignedAddDelegatorTx is an unsigned addDelegatorTx

func (*UnsignedAddDelegatorTx) EndTime added in v0.7.0

func (tx *UnsignedAddDelegatorTx) EndTime() time.Time

EndTime of this validator

func (*UnsignedAddDelegatorTx) InitiallyPrefersCommit added in v0.7.0

func (tx *UnsignedAddDelegatorTx) InitiallyPrefersCommit(vm *VM) bool

InitiallyPrefersCommit returns true if the proposed validators start time is after the current wall clock time,

func (*UnsignedAddDelegatorTx) SemanticVerify added in v0.7.0

func (tx *UnsignedAddDelegatorTx) SemanticVerify(
	vm *VM,
	db database.Database,
	stx *Tx,
) (
	*versiondb.Database,
	*versiondb.Database,
	func() error,
	func() error,
	TxError,
)

SemanticVerify this transaction is valid.

func (*UnsignedAddDelegatorTx) StartTime added in v0.7.0

func (tx *UnsignedAddDelegatorTx) StartTime() time.Time

StartTime of this validator

func (*UnsignedAddDelegatorTx) Verify added in v0.7.0

func (tx *UnsignedAddDelegatorTx) Verify(
	ctx *snow.Context,
	c codec.Codec,
	feeAmount uint64,
	feeAssetID ids.ID,
	minStake uint64,
) error

Verify return nil iff [tx] is valid

type UnsignedAddSubnetValidatorTx added in v0.7.0

type UnsignedAddSubnetValidatorTx struct {
	// Metadata, inputs and outputs
	BaseTx `serialize:"true"`
	// The validator
	Validator SubnetValidator `serialize:"true" json:"validator"`
	// Auth that will be allowing this validator into the network
	SubnetAuth verify.Verifiable `serialize:"true" json:"subnetAuthorization"`
}

UnsignedAddSubnetValidatorTx is an unsigned addSubnetValidatorTx

func (*UnsignedAddSubnetValidatorTx) EndTime added in v0.7.0

func (tx *UnsignedAddSubnetValidatorTx) EndTime() time.Time

EndTime of this validator

func (*UnsignedAddSubnetValidatorTx) InitiallyPrefersCommit added in v0.7.0

func (tx *UnsignedAddSubnetValidatorTx) InitiallyPrefersCommit(vm *VM) bool

InitiallyPrefersCommit returns true if the proposed validators start time is after the current wall clock time,

func (*UnsignedAddSubnetValidatorTx) SemanticVerify added in v0.7.0

func (tx *UnsignedAddSubnetValidatorTx) SemanticVerify(
	vm *VM,
	db database.Database,
	stx *Tx,
) (
	*versiondb.Database,
	*versiondb.Database,
	func() error,
	func() error,
	TxError,
)

SemanticVerify this transaction is valid.

func (*UnsignedAddSubnetValidatorTx) StartTime added in v0.7.0

func (tx *UnsignedAddSubnetValidatorTx) StartTime() time.Time

StartTime of this validator

func (*UnsignedAddSubnetValidatorTx) Verify added in v0.7.0

func (tx *UnsignedAddSubnetValidatorTx) Verify(
	ctx *snow.Context,
	c codec.Codec,
	feeAmount uint64,
	feeAssetID ids.ID,
) error

Verify return nil iff [tx] is valid

type UnsignedAddValidatorTx added in v0.7.0

type UnsignedAddValidatorTx struct {
	// Metadata, inputs and outputs
	BaseTx `serialize:"true"`
	// Describes the delegatee
	Validator Validator `serialize:"true" json:"validator"`
	// Where to send staked tokens when done validating
	Stake []*avax.TransferableOutput `serialize:"true" json:"stake"`
	// Where to send staking rewards when done validating
	RewardsOwner verify.Verifiable `serialize:"true" json:"rewardsOwner"`
	// Fee this validator charges delegators as a percentage, times 10,000
	// For example, if this validator has Shares=300,000 then they take 30% of rewards from delegators
	Shares uint32 `serialize:"true" json:"shares"`
}

UnsignedAddValidatorTx is an unsigned addValidatorTx

func (*UnsignedAddValidatorTx) EndTime added in v0.7.0

func (tx *UnsignedAddValidatorTx) EndTime() time.Time

EndTime of this validator

func (*UnsignedAddValidatorTx) InitiallyPrefersCommit added in v0.7.0

func (tx *UnsignedAddValidatorTx) InitiallyPrefersCommit(vm *VM) bool

InitiallyPrefersCommit returns true if the proposed validators start time is after the current wall clock time,

func (*UnsignedAddValidatorTx) SemanticVerify added in v0.7.0

func (tx *UnsignedAddValidatorTx) SemanticVerify(
	vm *VM,
	db database.Database,
	stx *Tx,
) (
	*versiondb.Database,
	*versiondb.Database,
	func() error,
	func() error,
	TxError,
)

SemanticVerify this transaction is valid.

func (*UnsignedAddValidatorTx) StartTime added in v0.7.0

func (tx *UnsignedAddValidatorTx) StartTime() time.Time

StartTime of this validator

func (*UnsignedAddValidatorTx) Verify added in v0.7.0

func (tx *UnsignedAddValidatorTx) Verify(
	ctx *snow.Context,
	c codec.Codec,
	feeAmount uint64,
	feeAssetID ids.ID,
	minStake uint64,
) error

Verify return nil iff [tx] is valid

type UnsignedAdvanceTimeTx added in v0.6.1

type UnsignedAdvanceTimeTx struct {
	avax.Metadata

	// Unix time this block proposes increasing the timestamp to
	Time uint64 `serialize:"true" json:"time"`
}

UnsignedAdvanceTimeTx is a transaction to increase the chain's timestamp. When the chain's timestamp is updated (a AdvanceTimeTx is accepted and followed by a commit block) the staker set is also updated accordingly. It must be that:

  • proposed timestamp > [current chain time]
  • proposed timestamp <= [time for next staker to be removed]

func (*UnsignedAdvanceTimeTx) InitiallyPrefersCommit added in v0.6.1

func (tx *UnsignedAdvanceTimeTx) InitiallyPrefersCommit(vm *VM) bool

InitiallyPrefersCommit returns true if the proposed time isn't after the current wall clock time.

func (*UnsignedAdvanceTimeTx) SemanticVerify added in v0.6.1

func (tx *UnsignedAdvanceTimeTx) SemanticVerify(
	vm *VM,
	db database.Database,
	stx *Tx,
) (
	*versiondb.Database,
	*versiondb.Database,
	func() error,
	func() error,
	TxError,
)

SemanticVerify this transaction is valid.

func (*UnsignedAdvanceTimeTx) Timestamp added in v0.6.1

func (tx *UnsignedAdvanceTimeTx) Timestamp() time.Time

Timestamp returns the time this block is proposing the chain should be set to

type UnsignedAtomicTx added in v0.6.1

type UnsignedAtomicTx interface {
	UnsignedTx

	// UTXOs this tx consumes
	InputUTXOs() ids.Set
	// Attempts to verify this transaction with the provided state.
	SemanticVerify(vm *VM, db database.Database, stx *Tx) TxError

	// Accept this transaction with the additionally provided state transitions.
	Accept(ctx *snow.Context, batch database.Batch) error
}

UnsignedAtomicTx is an unsigned operation that can be atomically accepted

type UnsignedCreateChainTx

type UnsignedCreateChainTx struct {
	// Metadata, inputs and outputs
	BaseTx `serialize:"true"`
	// ID of the Subnet that validates this blockchain
	SubnetID ids.ID `serialize:"true" json:"subnetID"`
	// A human readable name for the chain; need not be unique
	ChainName string `serialize:"true" json:"chainName"`
	// ID of the VM running on the new chain
	VMID ids.ID `serialize:"true" json:"vmID"`
	// IDs of the feature extensions running on the new chain
	FxIDs []ids.ID `serialize:"true" json:"fxIDs"`
	// Byte representation of genesis state of the new chain
	GenesisData []byte `serialize:"true" json:"genesisData"`
	// Auth that will be allowing this validator into the network
	SubnetAuth verify.Verifiable `serialize:"true" json:"subnetAuthorization"`
}

UnsignedCreateChainTx is an unsigned CreateChainTx

func (*UnsignedCreateChainTx) SemanticVerify added in v0.6.1

func (tx *UnsignedCreateChainTx) SemanticVerify(
	vm *VM,
	db database.Database,
	stx *Tx,
) (
	func() error,
	TxError,
)

SemanticVerify this transaction is valid.

func (*UnsignedCreateChainTx) Verify added in v0.6.1

func (tx *UnsignedCreateChainTx) Verify(
	ctx *snow.Context,
	c codec.Codec,
	feeAmount uint64,
	feeAssetID ids.ID,
) error

Verify this transaction is well-formed

type UnsignedCreateSubnetTx

type UnsignedCreateSubnetTx struct {
	// Metadata, inputs and outputs
	BaseTx `serialize:"true"`
	// Who is authorized to manage this subnet
	Owner verify.Verifiable `serialize:"true" json:"owner"`
}

UnsignedCreateSubnetTx is an unsigned proposal to create a new subnet

func (*UnsignedCreateSubnetTx) SemanticVerify added in v0.6.1

func (tx *UnsignedCreateSubnetTx) SemanticVerify(
	vm *VM,
	db database.Database,
	stx *Tx,
) (
	func() error,
	TxError,
)

SemanticVerify returns nil if [tx] is valid given the state in [db]

func (*UnsignedCreateSubnetTx) Verify added in v0.6.1

func (tx *UnsignedCreateSubnetTx) Verify(
	ctx *snow.Context,
	c codec.Codec,
	feeAmount uint64,
	feeAssetID ids.ID,
) error

Verify this transaction is well-formed

type UnsignedDecisionTx added in v0.6.1

type UnsignedDecisionTx interface {
	UnsignedTx

	// Attempts to verify this transaction with the provided state.
	SemanticVerify(vm *VM, db database.Database, stx *Tx) (
		onAcceptFunc func() error,
		err TxError,
	)
}

UnsignedDecisionTx is an unsigned operation that can be immediately decided

type UnsignedExportTx

type UnsignedExportTx struct {
	BaseTx `serialize:"true"`

	// Which chain to send the funds to
	DestinationChain ids.ID `serialize:"true" json:"destinationChain"`

	// Outputs that are exported to the chain
	ExportedOutputs []*avax.TransferableOutput `serialize:"true" json:"exportedOutputs"`
}

UnsignedExportTx is an unsigned ExportTx

func (*UnsignedExportTx) Accept added in v0.6.1

func (tx *UnsignedExportTx) Accept(ctx *snow.Context, batch database.Batch) error

Accept this transaction.

func (*UnsignedExportTx) InputUTXOs added in v0.6.1

func (tx *UnsignedExportTx) InputUTXOs() ids.Set

InputUTXOs returns an empty set

func (*UnsignedExportTx) SemanticVerify added in v0.6.1

func (tx *UnsignedExportTx) SemanticVerify(
	vm *VM,
	db database.Database,
	stx *Tx,
) TxError

SemanticVerify this transaction is valid.

func (*UnsignedExportTx) Verify added in v0.6.1

func (tx *UnsignedExportTx) Verify(
	avmID ids.ID,
	ctx *snow.Context,
	c codec.Codec,
	feeAmount uint64,
	feeAssetID ids.ID,
) error

Verify this transaction is well-formed

type UnsignedImportTx

type UnsignedImportTx struct {
	BaseTx `serialize:"true"`

	// Which chain to consume the funds from
	SourceChain ids.ID `serialize:"true" json:"sourceChain"`

	// Inputs that consume UTXOs produced on the chain
	ImportedInputs []*avax.TransferableInput `serialize:"true" json:"importedInputs"`
}

UnsignedImportTx is an unsigned ImportTx

func (*UnsignedImportTx) Accept added in v0.6.1

func (tx *UnsignedImportTx) Accept(ctx *snow.Context, batch database.Batch) error

Accept this transaction and spend imported inputs We spend imported UTXOs here rather than in semanticVerify because we don't want to remove an imported UTXO in semanticVerify only to have the transaction not be Accepted. This would be inconsistent. Recall that imported UTXOs are not kept in a versionDB.

func (*UnsignedImportTx) InputUTXOs added in v0.6.1

func (tx *UnsignedImportTx) InputUTXOs() ids.Set

InputUTXOs returns the UTXOIDs of the imported funds

func (*UnsignedImportTx) SemanticVerify added in v0.6.1

func (tx *UnsignedImportTx) SemanticVerify(
	vm *VM,
	db database.Database,
	stx *Tx,
) TxError

SemanticVerify this transaction is valid.

func (*UnsignedImportTx) Verify added in v0.6.1

func (tx *UnsignedImportTx) Verify(
	avmID ids.ID,
	ctx *snow.Context,
	c codec.Codec,
	feeAmount uint64,
	feeAssetID ids.ID,
) error

Verify this transaction is well-formed

type UnsignedProposalTx added in v0.6.1

type UnsignedProposalTx interface {
	UnsignedTx

	// Attempts to verify this transaction with the provided state.
	SemanticVerify(vm *VM, db database.Database, stx *Tx) (
		onCommitDB *versiondb.Database,
		onAbortDB *versiondb.Database,
		onCommitFunc func() error,
		onAbortFunc func() error,
		err TxError,
	)
	InitiallyPrefersCommit(vm *VM) bool
}

UnsignedProposalTx is an unsigned operation that can be proposed

type UnsignedRewardValidatorTx added in v0.6.1

type UnsignedRewardValidatorTx struct {
	avax.Metadata

	// ID of the tx that created the delegator/validator being removed/rewarded
	TxID ids.ID `serialize:"true" json:"txID"`
}

UnsignedRewardValidatorTx is a transaction that represents a proposal to remove a validator that is currently validating from the validator set.

If this transaction is accepted and the next block accepted is a Commit block, the validator is removed and the address that the validator specified receives the staked AVAX as well as a validating reward.

If this transaction is accepted and the next block accepted is an Abort block, the validator is removed and the address that the validator specified receives the staked AVAX but no reward.

func (*UnsignedRewardValidatorTx) InitiallyPrefersCommit added in v0.6.1

func (tx *UnsignedRewardValidatorTx) InitiallyPrefersCommit(*VM) bool

InitiallyPrefersCommit returns true.

Right now, *Commit (that is, remove the validator and reward them) is always preferred over *Abort (remove the validator but don't reward them.)

TODO: A validator should receive a reward only if they are sufficiently responsive and correct during the time they are validating.

func (*UnsignedRewardValidatorTx) SemanticVerify added in v0.6.1

func (tx *UnsignedRewardValidatorTx) SemanticVerify(
	vm *VM,
	db database.Database,
	stx *Tx,
) (
	*versiondb.Database,
	*versiondb.Database,
	func() error,
	func() error,
	TxError,
)

SemanticVerify this transaction performs a valid state transition.

The current validating set must have at least one member. The next validator to be removed must be the validator specified in this block. The next validator to be removed must be have an end time equal to the current

chain timestamp.

type UnsignedTx added in v0.6.1

type UnsignedTx interface {
	Initialize(unsignedBytes, signedBytes []byte)
	ID() ids.ID
	UnsignedBytes() []byte
	Bytes() []byte
}

UnsignedTx is an unsigned transaction

type VM

type VM struct {
	*core.SnowmanVM
	// contains filtered or unexported fields
}

VM implements the snowman.ChainVM interface

func (*VM) Bootstrapped added in v0.5.3

func (vm *VM) Bootstrapped() error

Bootstrapped marks this VM as bootstrapped

func (*VM) Bootstrapping added in v0.5.3

func (vm *VM) Bootstrapping() error

Bootstrapping marks this VM as bootstrapping

func (*VM) BuildBlock

func (vm *VM) BuildBlock() (snowman.Block, error)

BuildBlock builds a block to be added to consensus

func (*VM) Clock

func (vm *VM) Clock() *timer.Clock

Clock ...

func (*VM) Codec

func (vm *VM) Codec() codec.Codec

Codec ...

func (*VM) CreateHandlers

func (vm *VM) CreateHandlers() map[string]*common.HTTPHandler

CreateHandlers returns a map where: * keys are API endpoint extensions * values are API handlers See API documentation for more information

func (*VM) CreateStaticHandlers

func (vm *VM) CreateStaticHandlers() map[string]*common.HTTPHandler

CreateStaticHandlers implements the snowman.ChainVM interface

func (*VM) FormatAddress added in v0.5.3

func (vm *VM) FormatAddress(chainID ids.ID, addr ids.ShortID) (string, error)

FormatAddress takes in a chainID and a raw address and produces the formatted address

func (*VM) FormatLocalAddress added in v0.6.1

func (vm *VM) FormatLocalAddress(addr ids.ShortID) (string, error)

FormatLocalAddress takes in a raw address and produces the formatted address

func (*VM) GetAtomicUTXOs

func (vm *VM) GetAtomicUTXOs(
	chainID ids.ID,
	addrs ids.ShortSet,
	startAddr ids.ShortID,
	startUTXOID ids.ID,
	limit int,
) ([]*avax.UTXO, ids.ShortID, ids.ID, error)

GetAtomicUTXOs returns imported/exports UTXOs such that at least one of the addresses in [addrs] is referenced. Returns at most [limit] UTXOs. If [limit] <= 0 or [limit] > maxUTXOsToFetch, it is set to [maxUTXOsToFetch]. Returns: * The fetched of UTXOs * true if all there are no more UTXOs in this range to fetch * The address associated with the last UTXO fetched * The ID of the last UTXO fetched

func (*VM) GetBlock

func (vm *VM) GetBlock(blkID ids.ID) (snowman.Block, error)

GetBlock implements the snowman.ChainVM interface

func (*VM) GetUTXOs added in v0.6.1

func (vm *VM) GetUTXOs(
	db database.Database,
	addrs ids.ShortSet,
	startAddr ids.ShortID,
	startUTXOID ids.ID,
	limit int,
) ([]*avax.UTXO, ids.ShortID, ids.ID, error)

GetUTXOs returns UTXOs such that at least one of the addresses in [addrs] is referenced. Assumed elements of [addrs] are unique. Returns at most [limit] UTXOs. If [limit] <= 0 or [limit] > maxUTXOsToFetch, it is set to [maxUTXOsToFetch]. Only returns UTXOs associated with addresses >= [startAddr]. For address [startAddr], only returns UTXOs whose IDs are greater than [startUTXOID]. Returns: * The fetched of UTXOs * The address associated with the last UTXO fetched * The ID of the last UTXO fetched

func (*VM) Initialize

func (vm *VM) Initialize(
	ctx *snow.Context,
	db database.Database,
	genesisBytes []byte,
	msgs chan<- common.Message,
	_ []*common.Fx,
) error

Initialize this blockchain. [vm.ChainManager] and [vm.vdrMgr] must be set before this function is called.

func (*VM) Logger

func (vm *VM) Logger() logging.Logger

Logger ...

func (*VM) ParseAddress added in v0.5.3

func (vm *VM) ParseAddress(addrStr string) (ids.ID, ids.ShortID, error)

ParseAddress takes in an address and produces the ID of the chain it's for the ID of the address

func (*VM) ParseBlock

func (vm *VM) ParseBlock(bytes []byte) (snowman.Block, error)

ParseBlock implements the snowman.ChainVM interface

func (*VM) ParseLocalAddress added in v0.6.1

func (vm *VM) ParseLocalAddress(addrStr string) (ids.ShortID, error)

ParseLocalAddress takes in an address for this chain and produces the ID

func (*VM) SetPreference

func (vm *VM) SetPreference(blkID ids.ID)

SetPreference sets the preferred block to be the one with ID [blkID]

func (*VM) Shutdown

func (vm *VM) Shutdown() error

Shutdown this blockchain

type ValidatedByArgs

type ValidatedByArgs struct {
	// ValidatedBy returns the ID of the Subnet validating the blockchain with this ID
	BlockchainID ids.ID `json:"blockchainID"`
}

ValidatedByArgs is the arguments for calling ValidatedBy

type ValidatedByResponse

type ValidatedByResponse struct {
	// ID of the Subnet validating the specified blockchain
	SubnetID ids.ID `json:"subnetID"`
}

ValidatedByResponse is the reply from calling ValidatedBy

type ValidatesArgs

type ValidatesArgs struct {
	SubnetID ids.ID `json:"subnetID"`
}

ValidatesArgs are the arguments to Validates

type ValidatesResponse

type ValidatesResponse struct {
	BlockchainIDs []ids.ID `json:"blockchainIDs"`
}

ValidatesResponse is the response from calling Validates

type Validator

type Validator struct {
	// Node ID of the validator
	NodeID ids.ShortID `serialize:"true" json:"nodeID"`

	// Unix time this validator starts validating
	Start uint64 `serialize:"true" json:"start"`

	// Unix time this validator stops validating
	End uint64 `serialize:"true" json:"end"`

	// Weight of this validator used when sampling
	Wght uint64 `serialize:"true" json:"weight"`
}

Validator is a validator.

func (*Validator) BoundedBy added in v0.6.1

func (v *Validator) BoundedBy(startTime, endTime time.Time) bool

BoundedBy returns true iff the period that [validator] validates is a (non-strict) subset of the time that [other] validates. Namely, startTime <= v.StartTime() <= v.EndTime() <= endTime

func (*Validator) Duration added in v0.6.1

func (v *Validator) Duration() time.Duration

Duration is the amount of time that this validator will be in the validator set

func (*Validator) EndTime added in v0.6.1

func (v *Validator) EndTime() time.Time

EndTime is the time that this validator will leave the validator set

func (*Validator) ID

func (v *Validator) ID() ids.ShortID

ID returns the node ID of the validator

func (*Validator) StartTime added in v0.6.1

func (v *Validator) StartTime() time.Time

StartTime is the time that this validator will enter the validator set

func (*Validator) Verify added in v0.6.1

func (v *Validator) Verify() error

Verify validates the ID for this validator

func (*Validator) Weight

func (v *Validator) Weight() uint64

Weight is this validator's weight when sampling

Jump to

Keyboard shortcuts

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