Documentation
¶
Index ¶
- Constants
- type BCNType
- type BlockCache
- type BlockCacheImpl
- func (bc *BlockCacheImpl) Add(blk *block.Block) *BlockCacheNode
- func (bc *BlockCacheImpl) AddGenesis(blk *block.Block)
- func (bc *BlockCacheImpl) Del(bcn *BlockCacheNode)
- func (bc *BlockCacheImpl) Draw() string
- func (bc *BlockCacheImpl) Find(hash []byte) (*BlockCacheNode, error)
- func (bc *BlockCacheImpl) Flush(bcn *BlockCacheNode)
- func (bc *BlockCacheImpl) GetBlockByHash(hash []byte) (*block.Block, error)
- func (bc *BlockCacheImpl) GetBlockByNumber(num int64) (*block.Block, error)
- func (bc *BlockCacheImpl) Head() *BlockCacheNode
- func (bc *BlockCacheImpl) Link(bcn *BlockCacheNode)
- func (bc *BlockCacheImpl) LinkedRoot() *BlockCacheNode
- type BlockCacheNode
- type CacheStatus
- type WitnessList
- func (wl *WitnessList) Active() []string
- func (wl *WitnessList) CopyWitness(n *BlockCacheNode)
- func (wl *WitnessList) LibWitnessHandle()
- func (wl *WitnessList) NetID() []string
- func (wl *WitnessList) Pending() []string
- func (wl *WitnessList) PendingNum() int64
- func (wl *WitnessList) SetActive(al []string)
- func (wl *WitnessList) SetPending(pl []string)
- func (wl *WitnessList) SetPendingNum(n int64)
- func (wl *WitnessList) UpdateInfo(mv db.MVCCDB) error
- func (wl *WitnessList) UpdatePending(mv db.MVCCDB) error
Constants ¶
const ( // DelSingleBlockTime ... DelSingleBlockTime int64 = 10 )
const PICSIZE int = 1000
for debug draw the blockcache
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 (*BlockCacheImpl) Link ¶
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 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) 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