boltvm

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(contracts []*BoltContract) map[string]Contract

register contract

Types

type BoltContract

type BoltContract struct {
	// enable/disable bolt contract
	Enabled bool
	// contract name
	Name string
	// contract address
	Address string
	// Contract is contract object
	Contract Contract
}

type BoltStubImpl

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

func (*BoltStubImpl) Callee

func (b *BoltStubImpl) Callee() string

func (*BoltStubImpl) Caller

func (b *BoltStubImpl) Caller() string

func (*BoltStubImpl) CrossInvoke

func (b *BoltStubImpl) CrossInvoke(address, method string, args ...*pb.Arg) *Response

func (*BoltStubImpl) Delete

func (b *BoltStubImpl) Delete(key string)

func (*BoltStubImpl) Get

func (b *BoltStubImpl) Get(key string) (bool, []byte)

func (*BoltStubImpl) GetObject

func (b *BoltStubImpl) GetObject(key string, ret interface{}) bool

func (*BoltStubImpl) GetTxHash

func (b *BoltStubImpl) GetTxHash() types.Hash

GetTxHash returns the transaction hash

func (*BoltStubImpl) GetTxIndex

func (b *BoltStubImpl) GetTxIndex() uint64

func (*BoltStubImpl) Has

func (b *BoltStubImpl) Has(key string) bool

func (*BoltStubImpl) Logger

func (b *BoltStubImpl) Logger() logrus.FieldLogger

func (*BoltStubImpl) PostEvent

func (b *BoltStubImpl) PostEvent(event interface{})

func (*BoltStubImpl) PostInterchainEvent

func (b *BoltStubImpl) PostInterchainEvent(event interface{})

func (*BoltStubImpl) Query

func (b *BoltStubImpl) Query(prefix string) (bool, [][]byte)

func (*BoltStubImpl) Set

func (b *BoltStubImpl) Set(key string, value []byte)

func (*BoltStubImpl) SetObject

func (b *BoltStubImpl) SetObject(key string, value interface{})

func (*BoltStubImpl) ValidationEngine

func (b *BoltStubImpl) ValidationEngine() validator.Engine

type BoltVM

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

func New

func New(ctx *vm.Context, ve validator.Engine, contracts map[string]Contract) *BoltVM

New creates a blot vm object

func (*BoltVM) Run

func (bvm *BoltVM) Run(input []byte) (ret []byte, err error)

type Context

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

func NewContext

func NewContext(tx *pb.Transaction, txIndex uint64, data *pb.TransactionData, ledger ledger.Ledger, logger logrus.FieldLogger) *Context

func (*Context) Callee

func (ctx *Context) Callee() string

func (*Context) Caller

func (ctx *Context) Caller() string

func (*Context) Logger

func (ctx *Context) Logger() logrus.FieldLogger

func (*Context) TransactionHash

func (ctx *Context) TransactionHash() types.Hash

func (*Context) TransactionIndex

func (ctx *Context) TransactionIndex() uint64

type Contract

type Contract interface{}

func GetBoltContract

func GetBoltContract(address string, boltRegister map[string]Contract) (contract Contract, err error)

type Response

type Response struct {
	Ok     bool
	Result []byte
}

func Error

func Error(msg string) *Response

Error returns error result that will cause vm call error, and this transaction will be invalid

func Success

func Success(data []byte) *Response

Result returns normal result

type Stub

type Stub interface {
	// Caller
	Caller() string
	// Callee
	Callee() string
	// Logger
	Logger() logrus.FieldLogger
	// GetTxHash returns the transaction hash
	GetTxHash() types.Hash
	// GetTxIndex returns the transaction index in the block
	GetTxIndex() uint64
	// Has judges key
	Has(key string) bool
	// Get gets value from datastore by key
	Get(key string) (bool, []byte)
	// GetObject
	GetObject(key string, ret interface{}) bool
	// Set sets k-v
	Set(key string, value []byte)
	// SetObject sets k with object v, v will be marshaled using json
	SetObject(key string, value interface{})
	// Delete deletes k-v
	Delete(key string)
	// QueryByPrefix queries object by prefix
	Query(prefix string) (bool, [][]byte)
	// PostEvent posts event to external
	PostEvent(interface{})
	// PostInterchainEvent posts interchain event to external
	PostInterchainEvent(interface{})
	// Validator returns the instance of validator
	ValidationEngine() validator.Engine
	// CrossInvoke cross contract invoke
	CrossInvoke(address, method string, args ...*pb.Arg) *Response
}

Jump to

Keyboard shortcuts

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