pool

package
v1.2.3-alpha.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GOMAXPROCS       = runtime.NumCPU()
	ACCOUNT_PARALLEL = GOMAXPROCS
)

Functions

func NewPool

func NewPool(bc chainDb) *pool

Types

type BCPool

type BCPool struct {
	Id string

	LIMIT_HEIGHT      uint64
	LIMIT_LONGEST_NUM uint64
	// contains filtered or unexported fields
}

func (*BCPool) AddBlock

func (self *BCPool) AddBlock(block commonBlock)

func (*BCPool) CurrentChain

func (self *BCPool) CurrentChain() *forkedChain

func (*BCPool) CurrentModifyToChain

func (self *BCPool) CurrentModifyToChain(target *forkedChain, hashH *ledger.HashHeight) error

func (*BCPool) CurrentModifyToEmpty

func (self *BCPool) CurrentModifyToEmpty() error

func (*BCPool) LongerChain

func (self *BCPool) LongerChain(minHeight uint64) []*forkedChain

func (*BCPool) LongestChain

func (self *BCPool) LongestChain() *forkedChain

type BlockPool

type BlockPool interface {
	Writer
	Reader
	SnapshotProducerWriter
	Debug

	Start()
	Stop()
	Init(s syncer,
		wt *wallet.Manager,
		snapshotV *verifier.SnapshotVerifier,
		accountV *verifier.AccountVerifier)
	Details(addr *types.Address, hash types.Hash) string
}

type ByHeight

type ByHeight []commonBlock

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

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 Chain

type Chain interface {
	HeadHeight() uint64
	ChainId() string
	Head() commonBlock
	GetBlock(height uint64) commonBlock
}

type ChainReader

type ChainReader interface {
	Head() commonBlock
	GetBlock(height uint64) commonBlock
}

type Debug

type Debug interface {
	Info(addr *types.Address) string
	Snapshot() map[string]interface{}
	SnapshotPendingNum() uint64
	AccountPendingNum() *big.Int
	Account(addr types.Address) map[string]interface{}
	SnapshotChainDetail(chainId string) map[string]interface{}
	AccountChainDetail(addr types.Address, chainId string) map[string]interface{}
}

type ForkChainError

type ForkChainError struct {
	What string
}

func (ForkChainError) Error

func (e ForkChainError) Error() string

type ForkVersion

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

func (*ForkVersion) Inc

func (self *ForkVersion) Inc()

func (*ForkVersion) String

func (self *ForkVersion) String() string

func (*ForkVersion) Val

func (self *ForkVersion) Val() int

type MockChain

type MockChain struct {
}

func (*MockChain) DeleteAccountBlocks

func (*MockChain) DeleteAccountBlocks(addr *types.Address, toHeight uint64) (map[types.Address][]*ledger.AccountBlock, error)

func (*MockChain) DeleteSnapshotBlocksToHeight

func (*MockChain) DeleteSnapshotBlocksToHeight(toHeight uint64) ([]*ledger.SnapshotBlock, map[types.Address][]*ledger.AccountBlock, error)

func (*MockChain) GetAccountBlockByHash

func (*MockChain) GetAccountBlockByHash(blockHash *types.Hash) (*ledger.AccountBlock, error)

func (*MockChain) GetAccountBlockByHeight

func (*MockChain) GetAccountBlockByHeight(addr *types.Address, height uint64) (*ledger.AccountBlock, error)

func (*MockChain) GetFirstConfirmedAccountBlockBySbHeight

func (*MockChain) GetFirstConfirmedAccountBlockBySbHeight(snapshotBlockHeight uint64, addr *types.Address) (*ledger.AccountBlock, error)

func (*MockChain) GetLatestAccountBlock

func (*MockChain) GetLatestAccountBlock(addr *types.Address) (*ledger.AccountBlock, error)

func (*MockChain) GetLatestSnapshotBlock

func (*MockChain) GetLatestSnapshotBlock() *ledger.SnapshotBlock

func (*MockChain) GetSnapshotBlockByHash

func (*MockChain) GetSnapshotBlockByHash(hash *types.Hash) (*ledger.SnapshotBlock, error)

func (*MockChain) GetSnapshotBlockByHeight

func (*MockChain) GetSnapshotBlockByHeight(height uint64) (*ledger.SnapshotBlock, error)

func (*MockChain) GetUnConfirmAccountBlocks

func (*MockChain) GetUnConfirmAccountBlocks(addr *types.Address) []*ledger.AccountBlock

func (*MockChain) InsertAccountBlocks

func (*MockChain) InsertAccountBlocks(vmAccountBlocks []*vm_context.VmAccountBlock) error

func (*MockChain) InsertSnapshotBlock

func (*MockChain) InsertSnapshotBlock(snapshotBlock *ledger.SnapshotBlock) error

type MockSyncer

type MockSyncer struct {
}

func (*MockSyncer) BroadcastAccountBlock

func (*MockSyncer) BroadcastAccountBlock(block *ledger.AccountBlock)

func (*MockSyncer) BroadcastAccountBlocks

func (*MockSyncer) BroadcastAccountBlocks(blocks []*ledger.AccountBlock)

func (*MockSyncer) BroadcastSnapshotBlock

func (*MockSyncer) BroadcastSnapshotBlock(block *ledger.SnapshotBlock)

func (*MockSyncer) BroadcastSnapshotBlocks

func (*MockSyncer) BroadcastSnapshotBlocks(blocks []*ledger.SnapshotBlock)

func (*MockSyncer) FetchAccountBlocks

func (*MockSyncer) FetchAccountBlocks(start types.Hash, count uint64, address *types.Address)

func (*MockSyncer) FetchAccountBlocksWithHeight

func (*MockSyncer) FetchAccountBlocksWithHeight(start types.Hash, count uint64, address *types.Address, sHeight uint64)

func (*MockSyncer) FetchSnapshotBlocks

func (*MockSyncer) FetchSnapshotBlocks(start types.Hash, count uint64)

func (*MockSyncer) SubscribeAccountBlock

func (*MockSyncer) SubscribeAccountBlock(fn net.AccountblockCallback) (subId int)

func (*MockSyncer) SubscribeSnapshotBlock

func (*MockSyncer) SubscribeSnapshotBlock(fn net.SnapshotBlockCallback) (subId int)

func (*MockSyncer) SubscribeSyncStatus

func (*MockSyncer) SubscribeSyncStatus(fn net.SyncStateCallback) (subId int)

func (*MockSyncer) SyncState

func (*MockSyncer) SyncState() net.SyncState

func (*MockSyncer) UnsubscribeAccountBlock

func (*MockSyncer) UnsubscribeAccountBlock(subId int)

func (*MockSyncer) UnsubscribeSnapshotBlock

func (*MockSyncer) UnsubscribeSnapshotBlock(subId int)

func (*MockSyncer) UnsubscribeSyncStatus

func (*MockSyncer) UnsubscribeSyncStatus(subId int)

type Reader

type Reader interface {
	// received block in current? (key is requestHash)
	ExistInPool(address types.Address, requestHash types.Hash) bool
}

type SnapshotProducerWriter

type SnapshotProducerWriter interface {
	Lock()

	UnLock()

	AddDirectSnapshotBlock(block *ledger.SnapshotBlock) error

	RollbackAccountTo(addr types.Address, hash types.Hash, height uint64) error
}

type Writer

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

	// for contract account
	AddDirectAccountBlocks(address types.Address, received *vm_context.VmAccountBlock, sendBlocks []*vm_context.VmAccountBlock) error
}

Jump to

Keyboard shortcuts

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