pool

package
v2.6.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2019 License: GPL-3.0 Imports: 30 Imported by: 9

Documentation

Index

Constants

View Source
const (
	// DISCONNECT means that two branches are not connected
	DISCONNECT ChainState = 1
	// CONNECTED means that two branches are connected
	CONNECTED = 2
	// FORKED means that two branches are connected, but forked
	FORKED = 3
)

Variables

View Source
var ErrAllIn = errors.New("all in")
View Source
var ErrBlackList = errors.New("block in blacklist")
View Source
var ErrCurrentChainModify = errors.New("current chain modify")
View Source
var ErrEmptyMain = errors.New("empty chainpool")
View Source
var ErrMax = errors.New("arrived to max")
View Source
var ErrQuotaNotEnough = errors.New("block quota not enough")

Functions

This section is empty.

Types

type BCPool

type BCPool struct {
	ID string
	// contains filtered or unexported fields
}

BCPool is the basis for account pool and snapshot pool

func (*BCPool) CurrentChain

func (bcp *BCPool) CurrentChain() tree.Branch

CurrentChain returns the main branch

func (*BCPool) CurrentModifyToChain

func (bcp *BCPool) CurrentModifyToChain(target tree.Branch) error

CurrentModifyToChain switch target branch to main branch

func (*BCPool) CurrentModifyToEmpty

func (bcp *BCPool) CurrentModifyToEmpty() error

CurrentModifyToEmpty switch empty branch to main branch

func (*BCPool) LongerChain

func (bcp *BCPool) LongerChain(minHeight uint64) []tree.Branch

LongerChain looks for branches that are longer than insert new chainthe main branch

type Blacklist

type Blacklist interface {
	Add(key types.Hash)
	AddAddTimeout(key types.Hash, duration time.Duration)
	Exists(key types.Hash) bool
	Remove(key types.Hash)
}

Blacklist define a data set interface with a timeout

func NewBlacklist

func NewBlacklist() (Blacklist, error)

NewBlacklist returns timeout blacklist

type BlockPool

type BlockPool interface {
	Writer
	Reader
	SnapshotProducerWriter
	Debug

	Start()
	Stop()
	Init(s syncer,
		wt *wallet.Manager,
		snapshotV *verifier.SnapshotVerifier,
		accountV verifier.Verifier,
		cs consensus.Consensus)
}

BlockPool is responsible for organizing blocks and inserting it into the chain

func NewPool

func NewPool(bc chainDb) (BlockPool, error)

NewPool create a new BlockPool

type ByHeight

type ByHeight []commonBlock

ByHeight sorts commonBlock by height

func (ByHeight) Len

func (a ByHeight) Len() int

func (ByHeight) Less

func (a ByHeight) Less(i, j int) bool

func (ByHeight) Swap

func (a ByHeight) Swap(i, j int)

type ByTailHeight

type ByTailHeight []*snippetChain

ByTailHeight sorts snippetChain by tail height

func (ByTailHeight) Len

func (a ByTailHeight) Len() int

func (ByTailHeight) Less

func (a ByTailHeight) Less(i, j int) bool

func (ByTailHeight) Swap

func (a ByTailHeight) Swap(i, j int)

type ChainState

type ChainState uint8

ChainState represents the relationship between the two branches

type Debug

type Debug interface {
	Info() map[string]interface{}
	AccountBlockInfo(addr types.Address, hash types.Hash) interface{}
	SnapshotBlockInfo(hash types.Hash) interface{}
	Snapshot() map[string]interface{}
	SnapshotPendingNum() uint64
	AccountPendingNum() *big.Int
	Account(addr types.Address) map[string]interface{}
	SnapshotChainDetail(chainID string, height uint64) map[string]interface{}
	AccountChainDetail(addr types.Address, chainID string, height uint64) map[string]interface{}
}

Debug provide more detail info for BlockPool

type Reader

type Reader interface {
	GetIrreversibleBlock() *ledger.SnapshotBlock
}

Reader is a reader of BlockPool

type SnapshotProducerWriter

type SnapshotProducerWriter interface {
	lock.ChainInsert
	lock.ChainRollback
	AddDirectSnapshotBlock(block *ledger.SnapshotBlock) error
}

SnapshotProducerWriter is a writer for snapshot producer

type Writer

type Writer interface {
	// for normal account
	AddDirectAccountBlock(address types.Address, vmAccountBlock *vm_db.VmAccountBlock) error
}

Writer is a writer of BlockPool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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