Documentation
¶
Index ¶
- Variables
- type APIBlock
- type Block
- type Factory
- type GetBlockArgs
- type GetBlockReply
- type ProposeBlockArgs
- type ProposeBlockReply
- type Service
- type VM
- func (vm *VM) BuildBlock() (snowman.Block, error)
- func (vm *VM) CreateHandlers() map[string]*common.HTTPHandler
- func (vm *VM) CreateStaticHandlers() map[string]*common.HTTPHandler
- func (vm *VM) Health() (interface{}, error)
- func (vm *VM) Initialize(ctx *snow.Context, db database.Database, genesisData []byte, ...) error
- func (vm *VM) NewBlock(parentID ids.ID, height uint64, data [dataLen]byte, timestamp time.Time) (*Block, error)
- func (vm *VM) ParseBlock(bytes []byte) (snowman.Block, error)
Constants ¶
This section is empty.
Variables ¶
var (
ID = ids.ID{'t', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p'}
)
ID is a unique identifier for this VM
Functions ¶
This section is empty.
Types ¶
type APIBlock ¶
type APIBlock struct { Timestamp json.Uint64 `json:"timestamp"` // Timestamp of most recent block Data string `json:"data"` // Data in the most recent block. Base 58 repr. of 5 bytes. ID string `json:"id"` // String repr. of ID of the most recent block ParentID string `json:"parentID"` // String repr. of ID of the most recent block's parent }
APIBlock is the API representation of a block
type Block ¶
type Block struct { *core.Block `serialize:"true"` Data [dataLen]byte `serialize:"true"` Timestamp int64 `serialize:"true"` }
Block is a block on the chain. Each block contains: 1) A piece of data (a string) 2) A timestamp
type GetBlockArgs ¶
type GetBlockArgs struct { // ID of the block we're getting. // If left blank, gets the latest block ID string }
GetBlockArgs are the arguments to GetBlock
type GetBlockReply ¶
type GetBlockReply struct {
APIBlock
}
GetBlockReply is the reply from GetBlock
type ProposeBlockArgs ¶
type ProposeBlockArgs struct { // Data in the block. Must be base 58 encoding of 32 bytes. Data string `json:"data"` }
ProposeBlockArgs are the arguments to function ProposeValue
type ProposeBlockReply ¶
type ProposeBlockReply struct{ Success bool }
ProposeBlockReply is the reply from function ProposeBlock
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the API service for this VM
func (*Service) GetBlock ¶
func (s *Service) GetBlock(_ *http.Request, args *GetBlockArgs, reply *GetBlockReply) error
GetBlock gets the block whose ID is [args.ID] If [args.ID] is empty, get the latest block
func (*Service) ProposeBlock ¶
func (s *Service) ProposeBlock(_ *http.Request, args *ProposeBlockArgs, reply *ProposeBlockReply) error
ProposeBlock is an API method to propose a new block whose data is [args].Data. [args].Data must be a string repr. of a 32 byte array
type VM ¶
VM implements the snowman.VM interface Each block in this chain contains a Unix timestamp and a piece of data (a string)
func (*VM) BuildBlock ¶
BuildBlock returns a block that this vm wants to add to consensus
func (*VM) CreateHandlers ¶
func (vm *VM) CreateHandlers() map[string]*common.HTTPHandler
CreateHandlers returns a map where: Keys: The path extension for this VM's API (empty in this case) Values: The handler for the API
func (*VM) CreateStaticHandlers ¶
func (vm *VM) CreateStaticHandlers() map[string]*common.HTTPHandler
CreateStaticHandlers returns a map where: Keys: The path extension for this VM's static API Values: The handler for that static API We return nil because this VM has no static API
func (*VM) Initialize ¶
func (vm *VM) Initialize( ctx *snow.Context, db database.Database, genesisData []byte, toEngine chan<- common.Message, _ []*common.Fx, ) error
Initialize this vm [ctx] is this vm's context [db] is this vm's database [toEngine] is used to notify the consensus engine that new blocks are
ready to be added to consensus
The data in the genesis block is [genesisData]
func (*VM) NewBlock ¶
func (vm *VM) NewBlock(parentID ids.ID, height uint64, data [dataLen]byte, timestamp time.Time) (*Block, error)
NewBlock returns a new Block where: - the block's parent is [parentID] - the block's data is [data] - the block's timestamp is [timestamp] The block is persisted in storage