contract

package
v0.0.0-...-ee99c87 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2018 License: LGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

* * @file * @copyright defined in go-seele/LICENSE

* * This a temp file that mock the external APIs used in smart contract component. * It will be removed when blockchain infrastructure constructed, including account, * security, RPC, consensus and blockchain storage components. * * @file * @copyright defined in go-seele/LICENSE

Index

Constants

This section is empty.

Variables

View Source
var (
	// TxServ provide the transaction related service.
	// TODO initialize with the default implementation.
	TxServ TransactionService

	// ChainServ provide the blockchain related service.
	// TODO initialize with the default implementation.
	ChainServ BlockchainService
)

Functions

func Address

func Address(privKey *ecdsa.PrivateKey) string

Address returns account public address for the specified private key.

func HandleTransaction

func HandleTransaction(tx *Transaction)

HandleTransaction handles smart contract transation.

Types

type Account

type Account struct {
	AccountAddress string
	CodeAddress    string
	State          []byte
}

Account wraps the information of smart contract account.

type BlockchainService

type BlockchainService interface {
	// WriteContractAccount write contract account on blockchain.
	WriteContractAccount(account *Account)
	// GetContractAccount returns contract account of the specified address.
	GetContractAccount(address string) *Account

	// WriteCode write code on blockchain.
	WriteCode(codeAddress string, code []byte)
	// GetCode returns code of the specified address.
	GetCode(codeAddress string) []byte

	// WriteTransaction write transaction on blockchain.
	WriteTransaction(tx *Transaction)
}

BlockchainService is the interface for blockchain related operations.

type Operator

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

Operator wraps request operations of smart contract. All the operations should be signed.

func NewOperator

func NewOperator(privKey *ecdsa.PrivateKey) *Operator

NewOperator return a operator for smart contract operations.

func (*Operator) Destroy

func (operator *Operator) Destroy(contractAddress string)

Destroy the specified smart contract

func (*Operator) Invoke

func (operator *Operator) Invoke(contractAddress string, msg []byte)

Invoke smart contract with specified parameters.

func (*Operator) Register

func (operator *Operator) Register(code []byte)

Register a smart contract with specified code.

type Transaction

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

Transaction wraps the smart contract transaction.

type TransactionService

type TransactionService interface {
	// SendTransaction broadcast the smart contract transaction to P2P network for consensus.
	SendTransaction(tx *Transaction)

	// HandleTransaction handle the received smart contract transaction.
	HandleTransaction(tx *Transaction)
}

TransactionService is the interface for all transaction related operations.

type VM

type VM interface {
	Execute(code []byte, msg []byte)
}

VM is the interface of smart contract virtual machine.

Jump to

Keyboard shortcuts

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