contract

package
v0.8.8 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2017 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DeployAddr = []byte("00000000000000000000")

Functions

func DeSmartContractKey

func DeSmartContractKey(deKey string) (string, string)

func EnSmartContractKey

func EnSmartContractKey(scAddr string, key string) string

Types

type CacheKVs

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

type ContractStateDelta

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

type ILedgerSmartContract

type ILedgerSmartContract interface {
	GetTmpBalance(addr accounts.Address) (*big.Int, error)
	Height() (uint32, error)
}

type ISmartConstract

type ISmartConstract interface {
	GetState(key string) ([]byte, error)
	AddState(key string, value []byte)
	DelState(key string)
	GetBalances(addr string) (*big.Int, error)
	CurrentBlockHeight() uint32
	AddTransfer(fromAddr, toAddr string, amount *big.Int, txType uint32)
	SmartContractFailed()
	SmartContractCommitted()
}

type SmartConstract

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

State represents the account state

func NewSmartConstract

func NewSmartConstract(db *db.BlockchainDB, ledgerHandler ILedgerSmartContract) *SmartConstract

NewSmartConstract returns a new State

func (*SmartConstract) AddChangesForPersistence

func (sctx *SmartConstract) AddChangesForPersistence(writeBatch []*db.WriteBatch) ([]*db.WriteBatch, error)

AddChangesForPersistence put cache data into db

func (*SmartConstract) AddState

func (sctx *SmartConstract) AddState(key string, value []byte)

AddState put key-value into cache

func (*SmartConstract) AddTransfer

func (sctx *SmartConstract) AddTransfer(fromAddr, toAddr string, amount *big.Int, txType uint32)

AddTransfer add transfer to make new transaction

func (*SmartConstract) CurrentBlockHeight

func (sctx *SmartConstract) CurrentBlockHeight() uint32

CurrentBlockHeight get currentBlockHeight

func (*SmartConstract) DelState

func (sctx *SmartConstract) DelState(key string)

DelState remove key-value

func (*SmartConstract) ExecTransaction

func (sctx *SmartConstract) ExecTransaction(tx *types.Transaction, scAddr string)

ExecTransaction exec transaction

func (*SmartConstract) FinishContractTransaction

func (sctx *SmartConstract) FinishContractTransaction() (types.Transactions, error)

FinishContractTransaction finish contract transaction

func (*SmartConstract) GetBalances

func (sctx *SmartConstract) GetBalances(addr string) (*big.Int, error)

GetBalances get balance

func (*SmartConstract) GetState

func (sctx *SmartConstract) GetState(key string) ([]byte, error)

GetState get value

func (*SmartConstract) InProgress

func (sctx *SmartConstract) InProgress() bool

InProgress

func (*SmartConstract) SmartContractCommitted

func (sctx *SmartConstract) SmartContractCommitted()

SmartContractCommitted execute smartContract successfully

func (*SmartConstract) SmartContractFailed

func (sctx *SmartConstract) SmartContractFailed()

SmartContractFailed execute smartContract fail

func (*SmartConstract) StartConstract

func (sctx *SmartConstract) StartConstract(blockHeight uint32)

StartConstract start constract

func (*SmartConstract) StopContract

func (sctx *SmartConstract) StopContract(blockHeight uint32)

StopContract start contract

type StateExtra

type StateExtra struct {
	ContractStateDeltas map[string]*ContractStateDelta
	// contains filtered or unexported fields
}

func NewStateExtra

func NewStateExtra() *StateExtra

Jump to

Keyboard shortcuts

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