chainStructure

package
v0.0.0-...-fdc5c16 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2022 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlankApplication

type BlankApplication struct{}

func (BlankApplication) ApplicationInternalCall

func (BlankApplication) ApplicationInternalCall(src string, callData []byte) (ret interface{}, err error)

func (BlankApplication) Cancel

func (BlankApplication) Cancel(req blockchainRequest.Entity) (err error)

func (BlankApplication) Execute

func (BlankApplication) Execute(req blockchainRequest.Entity, header block.Entity, actIndex uint32) (result applicationResult.Entity, err error)

func (BlankApplication) GetActionAsRequest

func (BlankApplication) GetActionAsRequest(req blockchainRequest.Entity) (ret blockchainRequest.Entity)

func (BlankApplication) Information

func (BlankApplication) Information() (info service.BasicInformation)

func (BlankApplication) Name

func (BlankApplication) Name() (name string)

func (BlankApplication) PreExecute

func (BlankApplication) PreExecute(req blockchainRequest.Entity, header block.Entity) (result []byte, err error)

func (BlankApplication) PushClientRequest

func (BlankApplication) PushClientRequest(req blockchainRequest.Entity) (result interface{}, err error)

func (BlankApplication) Query

func (BlankApplication) Query(req []byte) (result interface{}, err error)

func (BlankApplication) RequestsForBlock

func (BlankApplication) RequestsForBlock(block block.Entity) (entity []blockchainRequest.Entity, cnt uint32)

func (BlankApplication) SetChainInterface

func (BlankApplication) SetChainInterface(ci IChainInterface)

func (BlankApplication) UnpackingActionsAsRequests

func (BlankApplication) UnpackingActionsAsRequests(req blockchainRequest.Entity) (reqList []blockchainRequest.Entity, err error)

type Blockchain

type Blockchain struct {
	Config   Config
	Executor applicationExecutor

	SQLStorage *chainSQLStorage.Storage
	// contains filtered or unexported fields
}

func (*Blockchain) AddBlock

func (b *Blockchain) AddBlock(blk block.Entity) (err error)

func (*Blockchain) CurrentHeight

func (b *Blockchain) CurrentHeight() uint64

func (*Blockchain) GetBlockByHeight

func (b *Blockchain) GetBlockByHeight(height uint64) (blk block.Entity, err error)

func (*Blockchain) GetBlockRowByHash

func (b *Blockchain) GetBlockRowByHash(hash string) (blk chainTables.BlockListRow, err error)

func (*Blockchain) GetBlockRowByHeight

func (b *Blockchain) GetBlockRowByHeight(height uint64) (blk chainTables.BlockListRow, err error)

func (*Blockchain) GetLastBlock

func (b *Blockchain) GetLastBlock() (last *block.Entity)

func (*Blockchain) InternalCall

func (b *Blockchain) InternalCall(src string, dst string, data []byte) (ret interface{}, err error)

func (*Blockchain) LoadBlockchain

func (b *Blockchain) LoadBlockchain(cfg Config) (err error)

func (*Blockchain) NewBlankBlock

func (b *Blockchain) NewBlankBlock() (newBlock block.Entity)

func (*Blockchain) NewBlock

func (b *Blockchain) NewBlock(requests []blockchainRequest.Entity, blankBlock block.Entity, lastBlock *block.Entity) (newBlock block.Entity)

func (*Blockchain) SetSQLStorage

func (b *Blockchain) SetSQLStorage(sqlStorage *chainSQLStorage.Storage)

type Config

type Config struct {
	Signer         signerCommon.ISigner
	CryptoTools    crypto.Tools
	NewWhenGenesis bool
	StorageDriver  kvDatabase.IDriver
	SQLStorage     *chainSQLStorage.Storage
}

type IBlockchainExternalApplication

type IBlockchainExternalApplication interface {
	Name() (name string)

	//receive a request from user
	PushClientRequest(req blockchainRequest.Entity) (result interface{}, err error)

	//query
	Query(req []byte) (result interface{}, err error)

	//receive and verify request from a block
	PreExecute(req blockchainRequest.Entity, header block.Entity) (result []byte, err error)

	//receive and execute confirmed block
	Execute(req blockchainRequest.Entity, header block.Entity, actIndex uint32) (result applicationResult.Entity, err error)

	//handle consensus failed
	Cancel(req blockchainRequest.Entity) (err error)

	//build request list for new block
	RequestsForBlock(block block.Entity) (entity []blockchainRequest.Entity, cnt uint32)

	//support one application call another inside blockchain execute
	ApplicationInternalCall(src string, callData []byte) (ret interface{}, err error)

	//external service information
	Information() (info service.BasicInformation)

	SetChainInterface(ci IChainInterface)

	UnpackingActionsAsRequests(req blockchainRequest.Entity) (reqList []blockchainRequest.Entity, err error)
	GetActionAsRequest(req blockchainRequest.Entity) (ret blockchainRequest.Entity)
}

type IChainInterface

type IChainInterface interface {
	GetBlockByHeight(height uint64) (blk block.Entity, err error)
	GetLastBlock() (last *block.Entity)
	CurrentHeight() (height uint64)
	InternalCall(src string, dst string, data []byte) (ret interface{}, err error)
}

Jump to

Keyboard shortcuts

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