blockcache

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2018 License: LGPL-3.0 Imports: 11 Imported by: 14

Documentation

Index

Constants

View Source
const (
	// DelSingleBlockTime ...
	DelSingleBlockTime int64 = 10
)
View Source
const PICSIZE int = 1000

for debug draw the blockcache

Variables

This section is empty.

Functions

This section is empty.

Types

type BCNType

type BCNType int

BCNType type of BlockCacheNode

const (
	// Linked ...
	Linked BCNType = iota
	// Single ...
	Single
	// Virtual ...
	Virtual
)

type BlockCache

type BlockCache interface {
	Add(*block.Block) *BlockCacheNode
	AddGenesis(*block.Block)
	Link(*BlockCacheNode)
	Del(*BlockCacheNode)
	Flush(*BlockCacheNode)
	Find([]byte) (*BlockCacheNode, error)
	GetBlockByNumber(int64) (*block.Block, error)
	GetBlockByHash([]byte) (*block.Block, error)
	LinkedRoot() *BlockCacheNode
	Head() *BlockCacheNode
	Draw() string
}

BlockCache defines BlockCache's API

type BlockCacheImpl

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

BlockCacheImpl is the implementation of BlockCache

func NewBlockCache

func NewBlockCache(baseVariable global.BaseVariable) (*BlockCacheImpl, error)

NewBlockCache return a new BlockCache instance

func (*BlockCacheImpl) Add

func (bc *BlockCacheImpl) Add(blk *block.Block) *BlockCacheNode

Add is add a block

func (*BlockCacheImpl) AddGenesis

func (bc *BlockCacheImpl) AddGenesis(blk *block.Block)

AddGenesis is add genesis block

func (*BlockCacheImpl) Del

func (bc *BlockCacheImpl) Del(bcn *BlockCacheNode)

Del is delete a block

func (*BlockCacheImpl) Draw

func (bc *BlockCacheImpl) Draw() string

Draw returns the linkedroot's and singleroot's tree graph.

func (*BlockCacheImpl) Find

func (bc *BlockCacheImpl) Find(hash []byte) (*BlockCacheNode, error)

Find is find the block

func (*BlockCacheImpl) Flush

func (bc *BlockCacheImpl) Flush(bcn *BlockCacheNode)

Flush is save a block

func (*BlockCacheImpl) GetBlockByHash

func (bc *BlockCacheImpl) GetBlockByHash(hash []byte) (*block.Block, error)

GetBlockByHash get a block by hash

func (*BlockCacheImpl) GetBlockByNumber

func (bc *BlockCacheImpl) GetBlockByNumber(num int64) (*block.Block, error)

GetBlockByNumber get a block by number

func (*BlockCacheImpl) Head

func (bc *BlockCacheImpl) Head() *BlockCacheNode

Head return head of block cache

func (bc *BlockCacheImpl) Link(bcn *BlockCacheNode)

Link call this when you run the block verify after Add() to ensure add single bcn to linkedRoot

func (*BlockCacheImpl) LinkedRoot

func (bc *BlockCacheImpl) LinkedRoot() *BlockCacheNode

LinkedRoot return the root node

type BlockCacheNode

type BlockCacheNode struct {
	Block        *block.Block
	Parent       *BlockCacheNode
	Children     map[*BlockCacheNode]bool
	Type         BCNType
	Number       int64
	Witness      string
	ConfirmUntil int64
	WitnessList
	Extension []byte
}

BlockCacheNode is the implementation of BlockCacheNode

func NewBCN

func NewBCN(parent *BlockCacheNode, block *block.Block) *BlockCacheNode

NewBCN return a new block cache node instance

func NewVirtualBCN

func NewVirtualBCN(parent *BlockCacheNode, block *block.Block) *BlockCacheNode

NewVirtualBCN return a new virtual block cache node instance

func (*BlockCacheNode) DrawTree

func (bcn *BlockCacheNode) DrawTree() string

DrawTree returns the the graph format of blockcache tree.

type CacheStatus

type CacheStatus int

CacheStatus ...

type WitnessList

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

WitnessList is the implementation of WitnessList

func (*WitnessList) Active

func (wl *WitnessList) Active() []string

Active get active witness list

func (*WitnessList) CopyWitness

func (wl *WitnessList) CopyWitness(n *BlockCacheNode)

CopyWitness is copy witness

func (*WitnessList) LibWitnessHandle

func (wl *WitnessList) LibWitnessHandle()

LibWitnessHandle is set active list

func (*WitnessList) NetID

func (wl *WitnessList) NetID() []string

NetID get net id

func (*WitnessList) Pending

func (wl *WitnessList) Pending() []string

Pending get pending witness list

func (*WitnessList) PendingNum

func (wl *WitnessList) PendingNum() int64

PendingNum get block number of pending witness

func (*WitnessList) SetActive

func (wl *WitnessList) SetActive(al []string)

SetActive set active witness list

func (*WitnessList) SetPending

func (wl *WitnessList) SetPending(pl []string)

SetPending set pending witness list

func (*WitnessList) SetPendingNum

func (wl *WitnessList) SetPendingNum(n int64)

SetPendingNum set block number of pending witness

func (*WitnessList) UpdateInfo

func (wl *WitnessList) UpdateInfo(mv db.MVCCDB) error

UpdateInfo update pending witness list

func (*WitnessList) UpdatePending

func (wl *WitnessList) UpdatePending(mv db.MVCCDB) error

UpdatePending update pending witness list

Jump to

Keyboard shortcuts

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