onroad

package
v2.9.0+incompatible Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: GPL-3.0 Imports: 26 Imported by: 8

Documentation

Index

Constants

View Source
const (
	// RETRY represents a state which the processor can retry to handle the onroad from a particular caller
	// to a particular contract in the next second during a block period.
	RETRY inferiorState = iota
	// OUT represents a state which the processor won't handle the onroad from a particular caller
	// to a particular contract during a block period any more.
	OUT
)

Variables

View Source
var (
	// POMAXPROCS is used to limit the use of number of operating system threads.
	POMAXPROCS = 2
	// ContractTaskProcessorSize is used to limit the number of processors.
	ContractTaskProcessorSize = POMAXPROCS
)

Functions

func ExcludePairTrades

func ExcludePairTrades(chain JudgeGenesis, blockList []*ledger.AccountBlock) map[types.Address][]*ledger.AccountBlock

ExcludePairTrades is to exclude the trade pairs.

Types

type ContractTaskProcessor

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

ContractTaskProcessor is to handle onroad and generate new contract receive block.

func NewContractTaskProcessor

func NewContractTaskProcessor(worker *ContractWorker, index int) *ContractTaskProcessor

NewContractTaskProcessor creates a ContractTaskProcessor.

type ContractWorker

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

ContractWorker managers the task processor, it also maintains the blacklist and queues with priority for callers.

func NewContractWorker

func NewContractWorker(manager *Manager) *ContractWorker

NewContractWorker creates a ContractWorker.

func (*ContractWorker) Close

func (w *ContractWorker) Close() error

Close is to stop the ContractWorker.

func (*ContractWorker) GetStakeQuota

func (w *ContractWorker) GetStakeQuota(addr types.Address) uint64

GetStakeQuota returns the available quota the contract can use at current.

func (*ContractWorker) GetStakeQuotas

func (w *ContractWorker) GetStakeQuotas(beneficialList []types.Address) map[types.Address]uint64

GetStakeQuotas returns the available quota the contract can use at current in batch.

func (*ContractWorker) Start

func (w *ContractWorker) Start(accEvent producerevent.AccountStartEvent)

Start is to start the ContractWorker's work, it listens to the event triggered by other module.

func (ContractWorker) Status

func (w ContractWorker) Status() int

Status returns the status of a ContractWorker.

func (*ContractWorker) Stop

func (w *ContractWorker) Stop()

Stop is to stop the ContractWorker and free up memory.

type JudgeGenesis

type JudgeGenesis interface {
	IsGenesisAccountBlock(block types.Hash) bool
}

JudgeGenesis is used for the method ExcludePairTrades.

type Manager

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

Manager implements contract's onRoad processing and cache management.

func NewManager

func NewManager(net netReader, pool pool, producer producer, consensus generator.Consensus, wallet *wallet.Manager) *Manager

NewManager creates a onroad Manager.

func (Manager) Chain

func (manager Manager) Chain() chain.Chain

Chain returns the instance of chain.

func (*Manager) Close

func (manager *Manager) Close() error

Close the model

func (Manager) Consensus

func (manager Manager) Consensus() generator.Consensus

Consensus returns the implementation of Consensus which manager is dependent on.

func (*Manager) DeleteAccountBlocks

func (manager *Manager) DeleteAccountBlocks(blocks []*ledger.AccountBlock) error

DeleteAccountBlocks method implements and listens to chain trigger event.

func (*Manager) DeleteSnapshotBlocks

func (manager *Manager) DeleteSnapshotBlocks(chunks []*ledger.SnapshotChunk) error

DeleteSnapshotBlocks method implements and listens to chain trigger event.

func (*Manager) GetAllCallersFrontOnRoad

func (manager *Manager) GetAllCallersFrontOnRoad(gid types.Gid, addr types.Address) ([]*ledger.AccountBlock, error)

GetAllCallersFrontOnRoad method returns all callers's front OnRoad blocks, those with the lowest height, in a contract OnRoad pool.

func (*Manager) GetOnRoadTotalNumByAddr

func (manager *Manager) GetOnRoadTotalNumByAddr(gid types.Gid, addr types.Address) (uint64, error)

GetOnRoadTotalNumByAddr method returns the total num of the contract' OnRoad blocks.

func (Manager) Info

func (manager Manager) Info() map[string]interface{}

Info returns the info of all contract.

func (*Manager) Init

func (manager *Manager) Init(chain chain.Chain)

Init is used to load all onroad into pool cache, for super node generating new contract receive block and for verifier module verifying the sequence of contract receive.

func (*Manager) InsertAccountBlocks

func (manager *Manager) InsertAccountBlocks(blocks []*vm_db.VmAccountBlock) error

InsertAccountBlocks method implements and listens to chain trigger event.

func (*Manager) InsertSnapshotBlocks

func (manager *Manager) InsertSnapshotBlocks(chunks []*ledger.SnapshotChunk) error

InsertSnapshotBlocks method implements and listens to chain trigger event.

func (*Manager) IsFrontOnRoadOfCaller

func (manager *Manager) IsFrontOnRoadOfCaller(gid types.Gid, orAddr, caller types.Address, hash types.Hash) (bool, error)

IsFrontOnRoadOfCaller method judges whether is the front OnRoad of a caller in a contract OnRoad pool.

func (Manager) Net

func (manager Manager) Net() netReader

Net returns the implementation of Net which manager is dependent on.

func (*Manager) PrepareDeleteAccountBlocks

func (manager *Manager) PrepareDeleteAccountBlocks(blocks []*ledger.AccountBlock) error

PrepareDeleteAccountBlocks method implements and listens to chain trigger event.

func (*Manager) PrepareDeleteSnapshotBlocks

func (manager *Manager) PrepareDeleteSnapshotBlocks(chunks []*ledger.SnapshotChunk) error

PrepareDeleteSnapshotBlocks method implements and listens to chain trigger event.

func (*Manager) PrepareInsertAccountBlocks

func (manager *Manager) PrepareInsertAccountBlocks(blocks []*vm_db.VmAccountBlock) error

PrepareInsertAccountBlocks method implements and listens to chain trigger event.

func (*Manager) PrepareInsertSnapshotBlocks

func (manager *Manager) PrepareInsertSnapshotBlocks(chunks []*ledger.SnapshotChunk) error

PrepareInsertSnapshotBlocks method implements and listens to chain trigger event.

func (Manager) Producer

func (manager Manager) Producer() producer

Producer returns the implementation of Producer which manager is dependent on.

func (*Manager) Start

func (manager *Manager) Start()

Start method subscribes the info of net, pool and chain module.

func (*Manager) Stop

func (manager *Manager) Stop()

Stop method cancel all subscriptions from other modules.

type Worker

type Worker interface {
	Status() int
	Start()
	Stop()
	Close() error
}

Worker lists the methods that the "Worker" need to be implemented.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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