vm

package
v0.1.1-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2018 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MountDir = "mountdir"

MountDir where block codes are stored

Functions

This section is empty.

Types

type Args

type Args struct {
	Func      string            `json:"func"`
	Payload   map[string][]byte `json:"payload"`
	Tx        *Tx               `json:"tx"`
	BlockInfo *BlockInfo        `json:"blockInfo"`
}

Args defines the structure of arguments sent to a blockcode

type Aux

type Aux struct {
	Image Image `json:"aux"`
}

Aux represents the aux structure in a docker image build response

type Block

type Block interface {
	GetTransactions() []*core.Transaction
}

Block defines an interface for a block

type BlockInfo

type BlockInfo struct {
	BlockNumber uint64
}

BlockInfo represents information about the current block

type Blockchain

type Blockchain interface {
	GetBlockCode(address string) (*blockcode.Blockcode, error)
}

Blockchain interface defines a structure for accessing the blockchain and all its primitives.

type BlockcodeMsg

type BlockcodeMsg struct {
	Type int               `json:"type"`
	Tx   *core.Transaction `json:"tx"`
}

BlockcodeMsg defines the message expected from a blockcode

type BuildContext

type BuildContext struct {
	Dir string
}

BuildContext for building a docker image

type BuildResponse

type BuildResponse struct {
	Stream string `json:"stream"`
}

BuildResponse that respresents a stream from docker build progression

type Container

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

Container defines the container that runs a block code.

func NewContainer

func NewContainer(dockerCli *docker.Client, img *Image, log logger.Logger) *Container

NewContainer creates a new container object

type ContainerManager

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

ContainerManager defines the module that manages containerization of Block codes and their execution

func NewContainerManager

func NewContainerManager(dockerClient *docker.Client, img *Image, log logger.Logger) *ContainerManager

NewContainerManager creates an instance of ContainerManager

type ContainerTransaction

type ContainerTransaction struct {
	Tx       *core.Transaction `json:"tx"`
	Function string            `json:"function"`
	Data     []byte            `json:"data"`
}

ContainerTransaction defines the structure of the blockcode transaction

type ExecRequest

type ExecRequest struct {
	Function string      `json:"Function"`
	Data     interface{} `json:"Data"`
}

ExecRequest defines the execution request to the blockcode stub

type Image

type Image struct {
	ID string `json:"ID"`
}

Image defines the structure of the final output of the image build

type ImageBuilder

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

ImageBuilder builds a struct

func NewImageBuilder

func NewImageBuilder(log logger.Logger, dockerClient *docker.Client, dockerFileURL string) *ImageBuilder

NewImageBuilder creates an instance of ImageBuilder

func (*ImageBuilder) Build

func (ib *ImageBuilder) Build() (*Image, error)

Build builds an image from a docker file gotten from the getDockerFile func - Checks if image already exists, else - Gets the docker file - Create an in-memory tar object and add the docker file to it - Create the build options - Build image in a separate go routine - Read the output - When build completes, check if image was created

type LangBuilder

type LangBuilder interface {
	GetRunScript() []string
	GetBuildScript() []string
}

LangBuilder provides information about how to build and run a blockcode of a specific language

type Result

type Result struct {
	Error bool        `json:"error"`
	Body  interface{} `json:"body"`
}

Result represents the output of a function call

type SampleBlockchain

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

SampleBlockchain defines a structure of a blockchain. This is for test only. Blockchains are more complex than this.

func NewSampleBlockchain

func NewSampleBlockchain() *SampleBlockchain

NewSampleBlockchain creates a SampleBlockchain

func (*SampleBlockchain) GetBlockCode

func (b *SampleBlockchain) GetBlockCode(address string) (*blockcode.Blockcode, error)

GetBlockCode returns a blockcode

type Tx

type Tx struct {
	ID    string `json:"txId"`
	Value string `json:"value"`
}

Tx represents details of an incoming transaction

type VM

type VM struct {
	InvokeResponseListener func(interface{})
	// contains filtered or unexported fields
}

VM specializes in executing transactions against a contracts

func New

func New(log logger.Logger, containerMountDir string) *VM

New creates a new instance of VM

func (*VM) Init

func (vm *VM) Init() error

Init sets up the environment for execution of contracts. - Create and connect docker client - Check if container mount directory exists, otherwise create it - Check if docker image exists, if not, fetch and build the image

Jump to

Keyboard shortcuts

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