filestoragevm

package
v0.0.0-...-06af98b Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: BSD-3-Clause Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Name = "filestoragevm"
)

Variables

View Source
var (
	Version = version.NewDefaultVersion(1, 0, 0)
)

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"`
}

Block is a block on the chain. Each block contains: 1) A piece of data (a string) 2) A timestamp

func (*Block) Verify

func (b *Block) Verify() error

Verify returns nil iff this block is valid. To be valid, it must be that: b.parent.Timestamp < b.Timestamp <= [local time] + 1 hour

type CreateAddressArgs

type CreateAddressArgs struct {
}

type CreateAddressReply

type CreateAddressReply struct {
	PrivateKey string `json:"privateKey"`
	PublicKey  string `json:"publicKey"`
}

type DebugPayloadArgs

type DebugPayloadArgs struct {
	Payload string
}

type DebugPayloadReply

type DebugPayloadReply struct {
	SigValid      bool   `json:"sigValid"`
	Sig           string `json:"sig"`
	Message       string `json:"message"`
	MessageLength int    `json:"messageLength"`
	Pubkey        string `json:"pubkey"`
}

type DecodeArgs

type DecodeArgs struct {
	Bytes    string              `json:"bytes"`
	Encoding formatting.Encoding `json:"encoding"`
}

DecodeArgs are arguments for Decode

type DecodeReply

type DecodeReply struct {
	Data     string              `json:"data"`
	Encoding formatting.Encoding `json:"encoding"`
}

DecodeReply is the reply from Decode

type EncodeArgs

type EncodeArgs struct {
	Data     string              `json:"data"`
	Encoding formatting.Encoding `json:"encoding"`
	Length   int32               `json:"length"`
}

EncodeArgs are arguments for Encode

type EncodeReply

type EncodeReply struct {
	Bytes    string              `json:"bytes"`
	Encoding formatting.Encoding `json:"encoding"`
}

EncodeReply is the reply from Encode

type Factory

type Factory struct{}

Factory ...

func (*Factory) New

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

New ...

type GetBalanceArgs

type GetBalanceArgs struct {
	Account string
}

type GetBalanceReply

type GetBalanceReply struct {
	Balance int64 `json:"balance"`
}

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 GetBlockHeightArgs

type GetBlockHeightArgs struct {
}

type GetBlockHeightReply

type GetBlockHeightReply struct {
	BlockHeight string `json:"blockHeight"`
}

type GetBlockReply

type GetBlockReply struct {
	APIBlock
}

GetBlockReply is the reply from GetBlock

type GetStorageCostArgs

type GetStorageCostArgs struct {
}

type GetStorageCostReply

type GetStorageCostReply struct {
	Cost int64 `json:"cost"`
}

type GetUnallocatedFundsArgs

type GetUnallocatedFundsArgs struct {
}

type GetUnallocatedFundsReply

type GetUnallocatedFundsReply struct {
	UnallocatedFunds int64 `json:"unallocatedFunds"`
}

type GetValidatorsAtArgs

type GetValidatorsAtArgs struct {
	Timestamp int64
	NodeID    string
}

type GetValidatorsAtReply

type GetValidatorsAtReply struct {
	Validators    map[string]uint64 `json:"validators"`
	Height        uint64            `json:"height"`
	WasValidating bool              `json:"wasValidating"`
}

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) CreateAddress

func (s *Service) CreateAddress(_ *http.Request, args *CreateAddressArgs, reply *CreateAddressReply) error

func (*Service) DebugPayload

func (s *Service) DebugPayload(_ *http.Request, args *DebugPayloadArgs, reply *DebugPayloadReply) error

func (*Service) GetBalance

func (s *Service) GetBalance(_ *http.Request, args *GetBalanceArgs, reply *GetBalanceReply) error

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) GetBlockHeight

func (s *Service) GetBlockHeight(_ *http.Request, args *GetBlockHeightArgs, reply *GetBlockHeightReply) error

func (*Service) GetStorageCost

func (s *Service) GetStorageCost(_ *http.Request, args *GetStorageCostArgs, reply *GetStorageCostReply) error

func (*Service) GetUnallocatedFunds

func (s *Service) GetUnallocatedFunds(_ *http.Request, args *GetUnallocatedFundsArgs, reply *GetUnallocatedFundsReply) error

func (*Service) GetValidatorsAt

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

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 StaticService

type StaticService struct{}

StaticService defines the base service for the timestamp vm

func CreateStaticService

func CreateStaticService() *StaticService

CreateStaticService ...

func (*StaticService) Decode

func (ss *StaticService) Decode(_ *http.Request, args *DecodeArgs, reply *DecodeReply) error

Decode returns the Decoded data

func (*StaticService) Encode

func (ss *StaticService) Encode(_ *http.Request, args *EncodeArgs, reply *EncodeReply) error

Encode returns the encoded data

type VM

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

VM implements the snowman.VM interface Each block in this chain contains a Unix timestamp and a piece of data (a string)

func (*VM) AppGossip

func (vm *VM) AppGossip(nodeID ids.ShortID, msg []byte) error

func (*VM) AppRequest

func (vm *VM) AppRequest(nodeID ids.ShortID, requestID uint32, request []byte) error

This VM doesn't (currently) have any app-specific messages

func (*VM) AppRequestFailed

func (vm *VM) AppRequestFailed(nodeID ids.ShortID, requestID uint32) error

This VM doesn't (currently) have any app-specific messages

func (*VM) AppResponse

func (vm *VM) AppResponse(nodeID ids.ShortID, requestID uint32, response []byte) error

This VM doesn't (currently) have any app-specific messages

func (*VM) BuildBlock

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

BuildBlock returns a block that this vm wants to add to consensus

func (*VM) Connected

func (vm *VM) Connected(id ids.ShortID) error

func (*VM) CreateHandlers

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

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, error)

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 CreateStaticHandlers implements the common.StaticVM interface

func (*VM) Disconnected

func (vm *VM) Disconnected(id ids.ShortID) error

func (*VM) HealthCheck

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

Health implements the common.VM interface

func (*VM) Initialize

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

Initialize this vm [ctx] is this vm's context [dbManager] is the manager of 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

func (*VM) ParseBlock

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

ParseBlock parses bytes to a snowman.Block This function is used by the vm's state to unmarshal blocks saved in state and by the consensus layer when it receives the byte representation of a block from another node

func (*VM) Version

func (vm *VM) Version() (string, error)

Returns this VM's version

Jump to

Keyboard shortcuts

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