platformvm

package
v1.9.6 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: BSD-3-Clause Imports: 59 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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 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 AddDelegatorArgs

type AddDelegatorArgs struct {
	// User, password, from addrs, change addr
	api.JSONSpendHeader
	platformapi.Staker
	RewardAddress string `json:"rewardAddress"`
}

AddDelegatorArgs are the arguments to AddDelegator

type AddSubnetValidatorArgs

type AddSubnetValidatorArgs struct {
	// User, password, from addrs, change addr
	api.JSONSpendHeader
	platformapi.Staker
	// ID of subnet to validate
	SubnetID string `json:"subnetID"`
}

AddSubnetValidatorArgs are the arguments to AddSubnetValidator

type AddValidatorArgs

type AddValidatorArgs struct {
	// User, password, from addrs, change addr
	api.JSONSpendHeader
	platformapi.Staker
	// The address the staking reward, if applicable, will go to
	RewardAddress     string       `json:"rewardAddress"`
	DelegationFeeRate json.Float32 `json:"delegationFeeRate"`
}

AddValidatorArgs are the arguments to AddValidator

type Client

type Client interface {
	// GetHeight returns the current block height of the P Chain
	GetHeight(ctx context.Context, options ...rpc.Option) (uint64, error)
	// ExportKey returns the private key corresponding to [address] from [user]'s account
	ExportKey(ctx context.Context, user api.UserPass, address ids.ShortID, options ...rpc.Option) (*crypto.PrivateKeySECP256K1R, error)
	// ImportKey imports the specified [privateKey] to [user]'s keystore
	ImportKey(ctx context.Context, user api.UserPass, privateKey *crypto.PrivateKeySECP256K1R, options ...rpc.Option) (ids.ShortID, error)
	// GetBalance returns the balance of [addrs] on the P Chain
	GetBalance(ctx context.Context, addrs []ids.ShortID, options ...rpc.Option) (*GetBalanceResponse, error)
	// CreateAddress creates a new address for [user]
	CreateAddress(ctx context.Context, user api.UserPass, options ...rpc.Option) (ids.ShortID, error)
	// ListAddresses returns an array of platform addresses controlled by [user]
	ListAddresses(ctx context.Context, user api.UserPass, options ...rpc.Option) ([]ids.ShortID, error)
	// GetUTXOs returns the byte representation of the UTXOs controlled by [addrs]
	GetUTXOs(
		ctx context.Context,
		addrs []ids.ShortID,
		limit uint32,
		startAddress ids.ShortID,
		startUTXOID ids.ID,
		options ...rpc.Option,
	) ([][]byte, ids.ShortID, ids.ID, error)
	// GetAtomicUTXOs returns the byte representation of the atomic UTXOs controlled by [addrs]
	// from [sourceChain]
	GetAtomicUTXOs(
		ctx context.Context,
		addrs []ids.ShortID,
		sourceChain string,
		limit uint32,
		startAddress ids.ShortID,
		startUTXOID ids.ID,
		options ...rpc.Option,
	) ([][]byte, ids.ShortID, ids.ID, error)
	// GetSubnets returns information about the specified subnets
	GetSubnets(ctx context.Context, subnetIDs []ids.ID, options ...rpc.Option) ([]ClientSubnet, error)
	// GetStakingAssetID returns the assetID of the asset used for staking on
	// subnet corresponding to [subnetID]
	GetStakingAssetID(ctx context.Context, subnetID ids.ID, options ...rpc.Option) (ids.ID, error)
	// GetCurrentValidators returns the list of current validators for subnet with ID [subnetID]
	GetCurrentValidators(ctx context.Context, subnetID ids.ID, nodeIDs []ids.NodeID, options ...rpc.Option) ([]ClientPermissionlessValidator, error)
	// GetPendingValidators returns the list of pending validators for subnet with ID [subnetID]
	GetPendingValidators(ctx context.Context, subnetID ids.ID, nodeIDs []ids.NodeID, options ...rpc.Option) ([]interface{}, []interface{}, error)
	// GetCurrentSupply returns an upper bound on the supply of AVAX in the system
	GetCurrentSupply(ctx context.Context, subnetID ids.ID, options ...rpc.Option) (uint64, error)
	// SampleValidators returns the nodeIDs of a sample of [sampleSize] validators from the current validator set for subnet with ID [subnetID]
	SampleValidators(ctx context.Context, subnetID ids.ID, sampleSize uint16, options ...rpc.Option) ([]ids.NodeID, error)
	// AddValidator issues a transaction to add a validator to the primary network
	// and returns the txID
	AddValidator(
		ctx context.Context,
		user api.UserPass,
		from []ids.ShortID,
		changeAddr ids.ShortID,
		rewardAddress ids.ShortID,
		nodeID ids.NodeID,
		stakeAmount,
		startTime,
		endTime uint64,
		delegationFeeRate float32,
		options ...rpc.Option,
	) (ids.ID, error)
	// AddDelegator issues a transaction to add a delegator to the primary network
	// and returns the txID
	AddDelegator(
		ctx context.Context,
		user api.UserPass,
		from []ids.ShortID,
		changeAddr ids.ShortID,
		rewardAddress ids.ShortID,
		nodeID ids.NodeID,
		stakeAmount,
		startTime,
		endTime uint64,
		options ...rpc.Option,
	) (ids.ID, error)
	// AddSubnetValidator issues a transaction to add validator [nodeID] to subnet
	// with ID [subnetID] and returns the txID
	AddSubnetValidator(
		ctx context.Context,
		user api.UserPass,
		from []ids.ShortID,
		changeAddr ids.ShortID,
		subnetID ids.ID,
		nodeID ids.NodeID,
		stakeAmount,
		startTime,
		endTime uint64,
		options ...rpc.Option,
	) (ids.ID, error)
	// CreateSubnet issues a transaction to create [subnet] and returns the txID
	CreateSubnet(
		ctx context.Context,
		user api.UserPass,
		from []ids.ShortID,
		changeAddr ids.ShortID,
		controlKeys []ids.ShortID,
		threshold uint32,
		options ...rpc.Option,
	) (ids.ID, error)
	// ExportAVAX issues an ExportTx transaction and returns the txID
	ExportAVAX(
		ctx context.Context,
		user api.UserPass,
		from []ids.ShortID,
		changeAddr ids.ShortID,
		to ids.ShortID,
		toChainIDAlias string,
		amount uint64,
		options ...rpc.Option,
	) (ids.ID, error)
	// ImportAVAX issues an ImportTx transaction and returns the txID
	ImportAVAX(
		ctx context.Context,
		user api.UserPass,
		from []ids.ShortID,
		changeAddr ids.ShortID,
		to ids.ShortID,
		sourceChain string,
		options ...rpc.Option,
	) (ids.ID, error)
	// CreateBlockchain issues a CreateBlockchain transaction and returns the txID
	CreateBlockchain(
		ctx context.Context,
		user api.UserPass,
		from []ids.ShortID,
		changeAddr ids.ShortID,
		subnetID ids.ID,
		vmID string,
		fxIDs []string,
		name string,
		genesisData []byte,
		options ...rpc.Option,
	) (ids.ID, error)
	// GetBlockchainStatus returns the current status of blockchain with ID: [blockchainID]
	GetBlockchainStatus(ctx context.Context, blockchainID string, options ...rpc.Option) (status.BlockchainStatus, error)
	// ValidatedBy returns the ID of the Subnet that validates [blockchainID]
	ValidatedBy(ctx context.Context, blockchainID ids.ID, options ...rpc.Option) (ids.ID, error)
	// Validates returns the list of blockchains that are validated by the subnet with ID [subnetID]
	Validates(ctx context.Context, subnetID ids.ID, options ...rpc.Option) ([]ids.ID, error)
	// GetBlockchains returns the list of blockchains on the platform
	GetBlockchains(ctx context.Context, options ...rpc.Option) ([]APIBlockchain, error)
	// IssueTx issues the transaction and returns its txID
	IssueTx(ctx context.Context, tx []byte, options ...rpc.Option) (ids.ID, error)
	// GetTx returns the byte representation of the transaction corresponding to [txID]
	GetTx(ctx context.Context, txID ids.ID, options ...rpc.Option) ([]byte, error)
	// GetTxStatus returns the status of the transaction corresponding to [txID]
	GetTxStatus(ctx context.Context, txID ids.ID, options ...rpc.Option) (*GetTxStatusResponse, error)
	// AwaitTxDecided polls [GetTxStatus] until a status is returned that
	// implies the tx may be decided.
	AwaitTxDecided(
		ctx context.Context,
		txID ids.ID,
		freq time.Duration,
		options ...rpc.Option,
	) (*GetTxStatusResponse, error)
	// GetStake returns the amount of nAVAX that [addrs] have cumulatively
	// staked on the Primary Network.
	GetStake(ctx context.Context, addrs []ids.ShortID, options ...rpc.Option) (map[ids.ID]uint64, [][]byte, error)
	// GetMinStake returns the minimum staking amount in nAVAX for validators
	// and delegators respectively
	GetMinStake(ctx context.Context, subnetID ids.ID, options ...rpc.Option) (uint64, uint64, error)
	// GetTotalStake returns the total amount (in nAVAX) staked on the network
	GetTotalStake(ctx context.Context, subnetID ids.ID, options ...rpc.Option) (uint64, error)
	// GetMaxStakeAmount returns the maximum amount of nAVAX staking to the named
	// node during the time period.
	GetMaxStakeAmount(
		ctx context.Context,
		subnetID ids.ID,
		nodeID ids.NodeID,
		startTime uint64,
		endTime uint64,
		options ...rpc.Option,
	) (uint64, error)
	// GetRewardUTXOs returns the reward UTXOs for a transaction
	GetRewardUTXOs(context.Context, *api.GetTxArgs, ...rpc.Option) ([][]byte, error)
	// GetTimestamp returns the current chain timestamp
	GetTimestamp(ctx context.Context, options ...rpc.Option) (time.Time, error)
	// GetValidatorsAt returns the weights of the validator set of a provided subnet
	// at the specified height.
	GetValidatorsAt(ctx context.Context, subnetID ids.ID, height uint64, options ...rpc.Option) (map[ids.NodeID]uint64, error)
	// GetBlock returns the block with the given id.
	GetBlock(ctx context.Context, blockID ids.ID, options ...rpc.Option) ([]byte, error)
}

Client interface for interacting with the P Chain endpoint

func NewClient

func NewClient(uri string) Client

NewClient returns a Client for interacting with the P Chain endpoint

type ClientDelegator added in v1.8.4

type ClientDelegator struct {
	ClientStaker
	RewardOwner     *ClientOwner
	PotentialReward *uint64
}

ClientDelegator is the repr. of a delegator sent over client

type ClientOwner added in v1.8.4

type ClientOwner struct {
	Locktime  uint64
	Threshold uint32
	Addresses []ids.ShortID
}

ClientOwner is the repr. of a reward owner sent over client

type ClientPermissionlessValidator added in v1.8.4

type ClientPermissionlessValidator struct {
	ClientStaker
	ValidationRewardOwner *ClientOwner
	DelegationRewardOwner *ClientOwner
	PotentialReward       *uint64
	DelegationFee         float32
	Uptime                *float32
	Connected             *bool
	Signer                *signer.ProofOfPossession
	// The delegators delegating to this validator
	Delegators []ClientDelegator
}

ClientPermissionlessValidator is the repr. of a permissionless validator sent over client

type ClientStaker added in v1.8.4

type ClientStaker struct {
	// the txID of the transaction that added this staker.
	TxID ids.ID
	// the Unix time when they start staking
	StartTime uint64
	// the Unix time when they are done staking
	EndTime uint64
	// the validator weight when sampling validators
	Weight *uint64
	// the amount of tokens being staked.
	StakeAmount *uint64
	// the node ID of the staker
	NodeID ids.NodeID
}

ClientStaker is the representation of a staker sent via client.

type ClientSubnet added in v1.8.4

type ClientSubnet struct {
	// ID of the subnet
	ID ids.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 []ids.ShortID
	Threshold   uint32
}

ClientSubnet is a representation of a subnet used in client methods

type CreateBlockchainArgs

type CreateBlockchainArgs struct {
	// User, password, from addrs, change addr
	api.JSONSpendHeader
	// 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 string `json:"genesisData"`
	// Encoding format to use for genesis data
	Encoding formatting.Encoding `json:"encoding"`
}

CreateBlockchainArgs is the arguments for calling CreateBlockchain

type CreateSubnetArgs

type CreateSubnetArgs struct {
	// User, password, from addrs, change addr
	api.JSONSpendHeader
	// The ID member of APISubnet is ignored
	APISubnet
}

CreateSubnetArgs are the arguments to CreateSubnet

type ExportAVAXArgs

type ExportAVAXArgs struct {
	// User, password, from addrs, change addr
	api.JSONSpendHeader

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

	// Chain the funds are going to. Optional. Used if To address does not include the chainID.
	TargetChain string `json:"targetChain"`

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

ExportAVAXArgs are the arguments to ExportAVAX

type ExportKeyArgs

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

ExportKeyArgs are arguments for ExportKey

type ExportKeyReply

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

ExportKeyReply is the response for ExportKey

type Factory

type Factory struct {
	config.Config
}

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 GetBalanceRequest

type GetBalanceRequest struct {
	// TODO: remove Address
	Address   *string  `json:"address,omitempty"`
	Addresses []string `json:"addresses"`
}

type GetBalanceResponse

type GetBalanceResponse struct {
	// Balance, in nAVAX, of the address
	Balance             json.Uint64            `json:"balance"`
	Unlocked            json.Uint64            `json:"unlocked"`
	LockedStakeable     json.Uint64            `json:"lockedStakeable"`
	LockedNotStakeable  json.Uint64            `json:"lockedNotStakeable"`
	Balances            map[ids.ID]json.Uint64 `json:"balances"`
	Unlockeds           map[ids.ID]json.Uint64 `json:"unlockeds"`
	LockedStakeables    map[ids.ID]json.Uint64 `json:"lockedStakeables"`
	LockedNotStakeables map[ids.ID]json.Uint64 `json:"lockedNotStakeables"`
	UTXOIDs             []*avax.UTXOID         `json:"utxoIDs"`
}

Note: We explicitly duplicate AVAX out of the maps to ensure backwards compatibility.

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.BlockchainStatus `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 GetCurrentSupplyArgs added in v1.8.4

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

GetCurrentSupplyArgs are the arguments for calling GetCurrentSupply

type GetCurrentSupplyReply

type GetCurrentSupplyReply struct {
	Supply json.Uint64 `json:"supply"`
}

GetCurrentSupplyReply are the results from calling GetCurrentSupply

type GetCurrentValidatorsArgs

type GetCurrentValidatorsArgs struct {
	// Subnet we're listing the validators of
	// If omitted, defaults to primary network
	SubnetID ids.ID `json:"subnetID"`
	// NodeIDs of validators to request. If [NodeIDs]
	// is empty, it fetches all current validators. If
	// some nodeIDs are not currently validators, they
	// will be omitted from the response.
	NodeIDs []ids.NodeID `json:"nodeIDs"`
}

GetCurrentValidatorsArgs are the arguments for calling GetCurrentValidators

type GetCurrentValidatorsReply

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

GetCurrentValidatorsReply are the results from calling GetCurrentValidators. Each validator contains a list of delegators to itself.

type GetHeightResponse

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

type GetMaxStakeAmountArgs

type GetMaxStakeAmountArgs struct {
	SubnetID  ids.ID      `json:"subnetID"`
	NodeID    ids.NodeID  `json:"nodeID"`
	StartTime json.Uint64 `json:"startTime"`
	EndTime   json.Uint64 `json:"endTime"`
}

GetMaxStakeAmountArgs is the request for calling GetMaxStakeAmount.

type GetMaxStakeAmountReply

type GetMaxStakeAmountReply struct {
	Amount json.Uint64 `json:"amount"`
}

GetMaxStakeAmountReply is the response from calling GetMaxStakeAmount.

type GetMinStakeArgs added in v1.8.4

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

GetMinStakeArgs are the arguments for calling GetMinStake.

type GetMinStakeReply

type GetMinStakeReply struct {
	//  The minimum amount of tokens one must bond to be a validator
	MinValidatorStake json.Uint64 `json:"minValidatorStake"`
	// Minimum stake, in nAVAX, that can be delegated on the primary network
	MinDelegatorStake json.Uint64 `json:"minDelegatorStake"`
}

GetMinStakeReply is the response from calling GetMinStake.

type GetPendingValidatorsArgs

type GetPendingValidatorsArgs struct {
	// Subnet we're getting the pending validators of
	// If omitted, defaults to primary network
	SubnetID ids.ID `json:"subnetID"`
	// NodeIDs of validators to request. If [NodeIDs]
	// is empty, it fetches all pending validators. If
	// some requested nodeIDs are not pending validators,
	// they are omitted from the response.
	NodeIDs []ids.NodeID `json:"nodeIDs"`
}

GetPendingValidatorsArgs are the arguments for calling GetPendingValidators

type GetPendingValidatorsReply

type GetPendingValidatorsReply struct {
	Validators []interface{} `json:"validators"`
	Delegators []interface{} `json:"delegators"`
}

GetPendingValidatorsReply are the results from calling GetPendingValidators. Unlike GetCurrentValidatorsReply, each validator has a null delegator list.

type GetRewardUTXOsReply

type GetRewardUTXOsReply struct {
	// Number of UTXOs returned
	NumFetched json.Uint64 `json:"numFetched"`
	// The UTXOs
	UTXOs []string `json:"utxos"`
	// Encoding specifies the encoding format the UTXOs are returned in
	Encoding formatting.Encoding `json:"encoding"`
}

GetRewardUTXOsReply defines the GetRewardUTXOs replies returned from the API

type GetStakeArgs

type GetStakeArgs struct {
	api.JSONAddresses
	Encoding formatting.Encoding `json:"encoding"`
}

type GetStakeReply

type GetStakeReply struct {
	Staked  json.Uint64            `json:"staked"`
	Stakeds map[ids.ID]json.Uint64 `json:"stakeds"`
	// String representation of staked outputs
	// Each is of type avax.TransferableOutput
	Outputs []string `json:"stakedOutputs"`
	// Encoding of [Outputs]
	Encoding formatting.Encoding `json:"encoding"`
}

GetStakeReply is the response from calling GetStake.

type GetStakingAssetIDArgs

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

GetStakingAssetIDArgs are the arguments to GetStakingAssetID

type GetStakingAssetIDResponse

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 GetTimestampReply

type GetTimestampReply struct {
	// Current timestamp
	Timestamp time.Time `json:"timestamp"`
}

GetTimestampReply is the response from GetTimestamp

type GetTotalStakeArgs added in v1.8.4

type GetTotalStakeArgs struct {
	// Subnet we're getting the total stake
	// If omitted returns Primary network weight
	SubnetID ids.ID `json:"subnetID"`
}

GetTotalStakeArgs are the arguments for calling GetTotalStake

type GetTotalStakeReply

type GetTotalStakeReply struct {
	// TODO: deprecate one of these fields
	Stake  json.Uint64 `json:"stake"`
	Weight json.Uint64 `json:"weight"`
}

GetTotalStakeReply is the response from calling GetTotalStake.

type GetTxStatusArgs

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

type GetTxStatusResponse

type GetTxStatusResponse struct {
	Status status.Status `json:"status"`
	// Reason this tx was dropped.
	// Only non-empty if Status is dropped
	Reason string `json:"reason,omitempty"`
}

type GetValidatorsAtArgs

type GetValidatorsAtArgs struct {
	Height   json.Uint64 `json:"height"`
	SubnetID ids.ID      `json:"subnetID"`
}

GetValidatorsAtArgs is the response from GetValidatorsAt

type GetValidatorsAtReply

type GetValidatorsAtReply struct {
	// TODO should we change this to map[ids.NodeID]*validators.Validator?
	// We'd have to add a MarshalJSON method to validators.Validator.
	Validators map[ids.NodeID]uint64 `json:"validators"`
}

GetValidatorsAtReply is the response from GetValidatorsAt

type ImportAVAXArgs

type ImportAVAXArgs struct {
	// User, password, from addrs, change addr
	api.JSONSpendHeader

	// 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

type ImportKeyArgs struct {
	api.UserPass
	PrivateKey *crypto.PrivateKeySECP256K1R `json:"privateKey"`
}

ImportKeyArgs are arguments for ImportKey

type Index

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 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 []ids.NodeID `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

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

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

func (*Service) AddSubnetValidator

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

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

func (*Service) AddValidator

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

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

func (*Service) CreateAddress

func (s *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 (s *Service) CreateBlockchain(_ *http.Request, args *CreateBlockchainArgs, response *api.JSONTxIDChangeAddr) error

CreateBlockchain issues a transaction to create a new blockchain

func (*Service) CreateSubnet

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

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

func (*Service) ExportAVAX

func (s *Service) ExportAVAX(_ *http.Request, args *ExportAVAXArgs, response *api.JSONTxIDChangeAddr) 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

func (s *Service) ExportKey(_ *http.Request, args *ExportKeyArgs, reply *ExportKeyReply) error

ExportKey returns a private key from the provided user

func (*Service) GetBalance

func (s *Service) GetBalance(_ *http.Request, args *GetBalanceRequest, response *GetBalanceResponse) error

GetBalance gets the balance of an address

func (*Service) GetBlock

func (s *Service) GetBlock(_ *http.Request, args *api.GetBlockArgs, response *api.GetBlockResponse) error

func (*Service) GetBlockchainStatus

func (s *Service) GetBlockchainStatus(r *http.Request, args *GetBlockchainStatusArgs, reply *GetBlockchainStatusReply) error

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

func (*Service) GetBlockchains

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

GetBlockchains returns all of the blockchains that exist

func (*Service) GetCurrentSupply

func (s *Service) GetCurrentSupply(_ *http.Request, args *GetCurrentSupplyArgs, reply *GetCurrentSupplyReply) error

GetCurrentSupply returns an upper bound on the supply of AVAX in the system

func (*Service) GetCurrentValidators

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

GetCurrentValidators returns current validators and delegators

func (*Service) GetHeight

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

GetHeight returns the height of the last accepted block

func (*Service) GetMaxStakeAmount

func (s *Service) GetMaxStakeAmount(_ *http.Request, args *GetMaxStakeAmountArgs, reply *GetMaxStakeAmountReply) error

GetMaxStakeAmount returns the maximum amount of nAVAX staking to the named node during the time period.

func (*Service) GetMinStake

func (s *Service) GetMinStake(_ *http.Request, args *GetMinStakeArgs, reply *GetMinStakeReply) error

GetMinStake returns the minimum staking amount in nAVAX.

func (*Service) GetPendingValidators

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

GetPendingValidators returns the list of pending validators

func (*Service) GetRewardUTXOs

func (s *Service) GetRewardUTXOs(_ *http.Request, args *api.GetTxArgs, reply *GetRewardUTXOsReply) error

GetRewardUTXOs returns the UTXOs that were rewarded after the provided transaction's staking period ended.

func (*Service) GetStake

func (s *Service) GetStake(_ *http.Request, args *GetStakeArgs, response *GetStakeReply) error

GetStake returns the amount of nAVAX that [args.Addresses] have cumulatively staked on the Primary Network.

This method assumes that each stake output has only owner This method assumes only AVAX can be staked This method only concerns itself with the Primary Network, not subnets TODO: Improve the performance of this method by maintaining this data in a data structure rather than re-calculating it by iterating over stakers

func (*Service) GetStakingAssetID

func (s *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 (s *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) GetTimestamp

func (s *Service) GetTimestamp(_ *http.Request, _ *struct{}, reply *GetTimestampReply) error

GetTimestamp returns the current timestamp on chain.

func (*Service) GetTotalStake

func (s *Service) GetTotalStake(_ *http.Request, args *GetTotalStakeArgs, reply *GetTotalStakeReply) error

GetTotalStake returns the total amount staked on the Primary Network

func (*Service) GetTx

func (s *Service) GetTx(_ *http.Request, args *api.GetTxArgs, response *api.GetTxReply) error

GetTx gets a tx

func (*Service) GetTxStatus

func (s *Service) GetTxStatus(_ *http.Request, args *GetTxStatusArgs, response *GetTxStatusResponse) error

GetTxStatus gets a tx's status

func (*Service) GetUTXOs

func (s *Service) GetUTXOs(_ *http.Request, args *api.GetUTXOsArgs, response *api.GetUTXOsReply) error

GetUTXOs returns the UTXOs controlled by the given addresses

func (*Service) GetValidatorsAt

func (s *Service) GetValidatorsAt(r *http.Request, args *GetValidatorsAtArgs, reply *GetValidatorsAtReply) error

GetValidatorsAt returns the weights of the validator set of a provided subnet at the specified height.

func (*Service) ImportAVAX

func (s *Service) ImportAVAX(_ *http.Request, args *ImportAVAXArgs, response *api.JSONTxIDChangeAddr) 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

func (s *Service) ImportKey(_ *http.Request, args *ImportKeyArgs, reply *api.JSONAddress) error

ImportKey adds a private key to the provided user

func (*Service) IssueTx

func (s *Service) IssueTx(_ *http.Request, args *api.FormattedTx, response *api.JSONTxID) error

IssueTx issues a tx

func (*Service) ListAddresses

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

ListAddresses returns the addresses controlled by [args.Username]

func (*Service) SampleValidators

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

SampleValidators returns a sampling of the list of current validators

func (*Service) ValidatedBy

func (s *Service) ValidatedBy(r *http.Request, args *ValidatedByArgs, response *ValidatedByResponse) error

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

func (*Service) Validates

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

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

type VM

type VM struct {
	Factory
	blockbuilder.Builder
	// contains filtered or unexported fields
}

func (*VM) Clock

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

func (*VM) CodecRegistry

func (vm *VM) CodecRegistry() codec.Registry

func (*VM) Connected

func (vm *VM) Connected(_ context.Context, nodeID ids.NodeID, _ *version.Application) error

func (*VM) ConnectedSubnet added in v1.9.4

func (vm *VM) ConnectedSubnet(_ context.Context, nodeID ids.NodeID, subnetID ids.ID) error

func (*VM) CreateHandlers

func (vm *VM) CreateHandlers(context.Context) (map[string]*common.HTTPHandler, error)

CreateHandlers returns a map where: * keys are API endpoint extensions * values are API handlers

func (*VM) CreateStaticHandlers

func (*VM) CreateStaticHandlers(context.Context) (map[string]*common.HTTPHandler, error)

CreateStaticHandlers returns a map where: * keys are API endpoint extensions * values are API handlers

func (*VM) Disconnected

func (vm *VM) Disconnected(_ context.Context, nodeID ids.NodeID) error

func (*VM) GetBlock

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

func (*VM) GetCurrentHeight

func (vm *VM) GetCurrentHeight(context.Context) (uint64, error)

GetCurrentHeight returns the height of the last accepted block

func (*VM) GetMinimumHeight

func (vm *VM) GetMinimumHeight(ctx context.Context) (uint64, error)

GetMinimumHeight returns the height of the most recent block beyond the horizon of our recentlyAccepted window.

Because the time between blocks is arbitrary, we're only guaranteed that the window's configured TTL amount of time has passed once an element expires from the window.

To try to always return a block older than the window's TTL, we return the parent of the oldest element in the window (as an expired element is always guaranteed to be sufficiently stale). If we haven't expired an element yet in the case of a process restart, we default to the lastAccepted block's height which is likely (but not guaranteed) to also be older than the window's configured TTL.

If [UseCurrentHeight] is true, we will always return the last accepted block height as the minimum. This is used to trigger the proposervm on recently created subnets before [recentlyAcceptedWindowTTL].

func (*VM) GetSubnetID added in v1.9.5

func (vm *VM) GetSubnetID(_ context.Context, chainID ids.ID) (ids.ID, error)

GetCurrentHeight returns the height of the last accepted block

func (*VM) GetValidatorSet

func (vm *VM) GetValidatorSet(ctx context.Context, height uint64, subnetID ids.ID) (map[ids.NodeID]*validators.GetValidatorOutput, error)

GetValidatorSet returns the validator set at the specified height for the provided subnetID.

func (*VM) HealthCheck

func (vm *VM) HealthCheck(context.Context) (interface{}, error)

func (*VM) Initialize

func (vm *VM) Initialize(
	ctx context.Context,
	chainCtx *snow.Context,
	dbManager manager.Manager,
	genesisBytes []byte,
	_ []byte,
	_ []byte,
	toEngine chan<- common.Message,
	_ []*common.Fx,
	appSender common.AppSender,
) error

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

func (*VM) LastAccepted

func (vm *VM) LastAccepted(context.Context) (ids.ID, error)

LastAccepted returns the block most recently accepted

func (*VM) Logger

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

func (*VM) ParseBlock

func (vm *VM) ParseBlock(_ context.Context, b []byte) (snowman.Block, error)

func (*VM) SetPreference

func (vm *VM) SetPreference(_ context.Context, blkID ids.ID) error

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

func (*VM) SetState

func (vm *VM) SetState(_ context.Context, state snow.State) error

func (*VM) Shutdown

func (vm *VM) Shutdown(context.Context) error

Shutdown this blockchain

func (*VM) Version

func (*VM) Version(context.Context) (string, error)

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

Directories

Path Synopsis
Package blocks is a generated GoMock package.
Package blocks is a generated GoMock package.
executor
Package executor is a generated GoMock package.
Package executor is a generated GoMock package.
Package fx is a generated GoMock package.
Package fx is a generated GoMock package.
Package state is a generated GoMock package.
Package state is a generated GoMock package.
txs
Package txs is a generated GoMock package.
Package txs is a generated GoMock package.
builder
Package builder is a generated GoMock package.
Package builder is a generated GoMock package.
mempool
Package mempool is a generated GoMock package.
Package mempool is a generated GoMock package.
Package utxo is a generated GoMock package.
Package utxo is a generated GoMock package.

Jump to

Keyboard shortcuts

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