Documentation ¶
Index ¶
- Constants
- Variables
- type BCNType
- type BcMessage
- type BcMessageType
- func (BcMessageType) Descriptor() protoreflect.EnumDescriptor
- func (x BcMessageType) Enum() *BcMessageType
- func (BcMessageType) EnumDescriptor() ([]byte, []int)deprecated
- func (x BcMessageType) Number() protoreflect.EnumNumber
- func (x BcMessageType) String() string
- func (BcMessageType) Type() protoreflect.EnumType
- type BlockCache
- type BlockCacheImpl
- func (bc *BlockCacheImpl) Add(blk *block.Block) *BlockCacheNode
- func (bc *BlockCacheImpl) AddGenesis(blk *block.Block)
- func (bc *BlockCacheImpl) AddNodeToWAL(bcn *BlockCacheNode)
- func (bc *BlockCacheImpl) Del(bcn *BlockCacheNode)
- func (bc *BlockCacheImpl) Draw() string
- 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
- func (bc *BlockCacheImpl) Recover(p ConAlgo) (err error)
- func (bc *BlockCacheImpl) SetHead(n *BlockCacheNode)
- func (bc *BlockCacheImpl) SetLinkedRoot(n *BlockCacheNode)
- func (bc *BlockCacheImpl) UpdateLib(node *BlockCacheNode)
- type BlockCacheNode
- type BlockCacheRaw
- func (*BlockCacheRaw) Descriptor() ([]byte, []int)deprecated
- func (x *BlockCacheRaw) GetBlockBytes() []byte
- func (x *BlockCacheRaw) GetSerialNum() int64
- func (x *BlockCacheRaw) GetWitnessList() *WitnessList
- func (*BlockCacheRaw) ProtoMessage()
- func (x *BlockCacheRaw) ProtoReflect() protoreflect.Message
- func (x *BlockCacheRaw) Reset()
- func (x *BlockCacheRaw) String() string
- type CacheStatus
- type ConAlgo
- type UpdateActiveRaw
- func (*UpdateActiveRaw) Descriptor() ([]byte, []int)deprecated
- func (x *UpdateActiveRaw) GetBlockHashBytes() []byte
- func (x *UpdateActiveRaw) GetWitnessList() *WitnessList
- func (*UpdateActiveRaw) ProtoMessage()
- func (x *UpdateActiveRaw) ProtoReflect() protoreflect.Message
- func (x *UpdateActiveRaw) Reset()
- func (x *UpdateActiveRaw) String() string
- type UpdateLinkedRootWitnessRaw
- func (*UpdateLinkedRootWitnessRaw) Descriptor() ([]byte, []int)deprecated
- func (x *UpdateLinkedRootWitnessRaw) GetBlockHashBytes() []byte
- func (x *UpdateLinkedRootWitnessRaw) GetLinkedRootWitness() []string
- func (*UpdateLinkedRootWitnessRaw) ProtoMessage()
- func (x *UpdateLinkedRootWitnessRaw) ProtoReflect() protoreflect.Message
- func (x *UpdateLinkedRootWitnessRaw) Reset()
- func (x *UpdateLinkedRootWitnessRaw) String() string
- type WitnessInfo
- type WitnessList
- func (wl *WitnessList) Active() []string
- func (wl *WitnessList) CopyWitness(n *BlockCacheNode)
- func (*WitnessList) Descriptor() ([]byte, []int)deprecated
- func (x *WitnessList) GetActiveWitnessList() []string
- func (x *WitnessList) GetPendingWitnessList() []string
- func (x *WitnessList) GetPendingWitnessNumber() int64
- func (x *WitnessList) GetWitnessInfo() []string
- func (wl *WitnessList) NetID() []string
- func (wl *WitnessList) Pending() []string
- func (*WitnessList) ProtoMessage()
- func (x *WitnessList) ProtoReflect() protoreflect.Message
- func (x *WitnessList) Reset()
- func (wl *WitnessList) SetActive(al []string)
- func (wl *WitnessList) SetPending(pl []string)
- func (x *WitnessList) String() string
- func (wl *WitnessList) UpdateInfo(mv database.IMultiValue, rules *version.Rules) error
- type WitnessStatus
Constants ¶
const ( // DelSingleBlockTime ... DelSingleBlockTime int64 = 10 )
Variables ¶
var ( BcMessageType_name = map[int32]string{ 0: "LinkType", 1: "UpdateActiveType", 2: "UpdateLinkedRootWitnessType", } BcMessageType_value = map[string]int32{ "LinkType": 0, "UpdateActiveType": 1, "UpdateLinkedRootWitnessType": 2, } )
Enum value maps for BcMessageType.
var (
BlockCacheWALDir = "./BlockCacheWAL"
)
The directory of block cache wal.
var File_core_blockcache_block_cache_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type BcMessage ¶
type BcMessage struct { Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` Type BcMessageType `protobuf:"varint,2,opt,name=type,proto3,enum=blockcache.BcMessageType" json:"type,omitempty"` // contains filtered or unexported fields }
func (*BcMessage) Descriptor
deprecated
func (*BcMessage) GetType ¶
func (x *BcMessage) GetType() BcMessageType
func (*BcMessage) ProtoMessage ¶
func (*BcMessage) ProtoMessage()
func (*BcMessage) ProtoReflect ¶
func (x *BcMessage) ProtoReflect() protoreflect.Message
type BcMessageType ¶
type BcMessageType int32
const ( BcMessageType_LinkType BcMessageType = 0 BcMessageType_UpdateActiveType BcMessageType = 1 BcMessageType_UpdateLinkedRootWitnessType BcMessageType = 2 )
func (BcMessageType) Descriptor ¶
func (BcMessageType) Descriptor() protoreflect.EnumDescriptor
func (BcMessageType) Enum ¶
func (x BcMessageType) Enum() *BcMessageType
func (BcMessageType) EnumDescriptor
deprecated
func (BcMessageType) EnumDescriptor() ([]byte, []int)
Deprecated: Use BcMessageType.Descriptor instead.
func (BcMessageType) Number ¶
func (x BcMessageType) Number() protoreflect.EnumNumber
func (BcMessageType) String ¶
func (x BcMessageType) String() string
func (BcMessageType) Type ¶
func (BcMessageType) Type() protoreflect.EnumType
type BlockCache ¶
type BlockCache interface { Add(*block.Block) *BlockCacheNode AddGenesis(*block.Block) Link(*BlockCacheNode) UpdateLib(*BlockCacheNode) Del(*BlockCacheNode) GetBlockByNumber(int64) (*block.Block, error) GetBlockByHash([]byte) (*block.Block, error) LinkedRoot() *BlockCacheNode Head() *BlockCacheNode Draw() string Recover(p ConAlgo) (err error) AddNodeToWAL(bcn *BlockCacheNode) }
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(conf *common.Config, bChain block.Chain, stateDB db.MVCCDB) (*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) AddNodeToWAL ¶
func (bc *BlockCacheImpl) AddNodeToWAL(bcn *BlockCacheNode)
AddNodeToWAL add write node message to WAL
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) 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
func (*BlockCacheImpl) Recover ¶
func (bc *BlockCacheImpl) Recover(p ConAlgo) (err error)
Recover recover previews block cache
func (*BlockCacheImpl) SetHead ¶
func (bc *BlockCacheImpl) SetHead(n *BlockCacheNode)
SetHead sets head blockcache node.
func (*BlockCacheImpl) SetLinkedRoot ¶
func (bc *BlockCacheImpl) SetLinkedRoot(n *BlockCacheNode)
SetLinkedRoot sets linked blockcache node.
func (*BlockCacheImpl) UpdateLib ¶
func (bc *BlockCacheImpl) UpdateLib(node *BlockCacheNode)
UpdateLib will update last inreversible block
type BlockCacheNode ¶
type BlockCacheNode struct { *block.Block *WitnessList Children map[*BlockCacheNode]bool Type BCNType ValidWitness []string SerialNum int64 // contains filtered or unexported fields }
BlockCacheNode is the implementation of BlockCacheNode
func NewBCN ¶
func NewBCN(parent *BlockCacheNode, blk *block.Block) *BlockCacheNode
NewBCN return a new block cache node instance
func (*BlockCacheNode) GetParent ¶
func (bcn *BlockCacheNode) GetParent() *BlockCacheNode
GetParent returns the node's parent node.
func (*BlockCacheNode) SetParent ¶
func (bcn *BlockCacheNode) SetParent(p *BlockCacheNode)
SetParent sets the node's parent.
type BlockCacheRaw ¶
type BlockCacheRaw struct { BlockBytes []byte `protobuf:"bytes,1,opt,name=blockBytes,proto3" json:"blockBytes,omitempty"` WitnessList *WitnessList `protobuf:"bytes,2,opt,name=witnessList,proto3" json:"witnessList,omitempty"` SerialNum int64 `protobuf:"varint,3,opt,name=serialNum,proto3" json:"serialNum,omitempty"` // contains filtered or unexported fields }
func (*BlockCacheRaw) Descriptor
deprecated
func (*BlockCacheRaw) Descriptor() ([]byte, []int)
Deprecated: Use BlockCacheRaw.ProtoReflect.Descriptor instead.
func (*BlockCacheRaw) GetBlockBytes ¶
func (x *BlockCacheRaw) GetBlockBytes() []byte
func (*BlockCacheRaw) GetSerialNum ¶
func (x *BlockCacheRaw) GetSerialNum() int64
func (*BlockCacheRaw) GetWitnessList ¶
func (x *BlockCacheRaw) GetWitnessList() *WitnessList
func (*BlockCacheRaw) ProtoMessage ¶
func (*BlockCacheRaw) ProtoMessage()
func (*BlockCacheRaw) ProtoReflect ¶
func (x *BlockCacheRaw) ProtoReflect() protoreflect.Message
func (*BlockCacheRaw) Reset ¶
func (x *BlockCacheRaw) Reset()
func (*BlockCacheRaw) String ¶
func (x *BlockCacheRaw) String() string
type UpdateActiveRaw ¶
type UpdateActiveRaw struct { BlockHashBytes []byte `protobuf:"bytes,1,opt,name=blockHashBytes,proto3" json:"blockHashBytes,omitempty"` WitnessList *WitnessList `protobuf:"bytes,2,opt,name=witnessList,proto3" json:"witnessList,omitempty"` // contains filtered or unexported fields }
func (*UpdateActiveRaw) Descriptor
deprecated
func (*UpdateActiveRaw) Descriptor() ([]byte, []int)
Deprecated: Use UpdateActiveRaw.ProtoReflect.Descriptor instead.
func (*UpdateActiveRaw) GetBlockHashBytes ¶
func (x *UpdateActiveRaw) GetBlockHashBytes() []byte
func (*UpdateActiveRaw) GetWitnessList ¶
func (x *UpdateActiveRaw) GetWitnessList() *WitnessList
func (*UpdateActiveRaw) ProtoMessage ¶
func (*UpdateActiveRaw) ProtoMessage()
func (*UpdateActiveRaw) ProtoReflect ¶
func (x *UpdateActiveRaw) ProtoReflect() protoreflect.Message
func (*UpdateActiveRaw) Reset ¶
func (x *UpdateActiveRaw) Reset()
func (*UpdateActiveRaw) String ¶
func (x *UpdateActiveRaw) String() string
type UpdateLinkedRootWitnessRaw ¶
type UpdateLinkedRootWitnessRaw struct { LinkedRootWitness []string `protobuf:"bytes,1,rep,name=linkedRootWitness,proto3" json:"linkedRootWitness,omitempty"` BlockHashBytes []byte `protobuf:"bytes,2,opt,name=blockHashBytes,proto3" json:"blockHashBytes,omitempty"` // contains filtered or unexported fields }
func (*UpdateLinkedRootWitnessRaw) Descriptor
deprecated
func (*UpdateLinkedRootWitnessRaw) Descriptor() ([]byte, []int)
Deprecated: Use UpdateLinkedRootWitnessRaw.ProtoReflect.Descriptor instead.
func (*UpdateLinkedRootWitnessRaw) GetBlockHashBytes ¶
func (x *UpdateLinkedRootWitnessRaw) GetBlockHashBytes() []byte
func (*UpdateLinkedRootWitnessRaw) GetLinkedRootWitness ¶
func (x *UpdateLinkedRootWitnessRaw) GetLinkedRootWitness() []string
func (*UpdateLinkedRootWitnessRaw) ProtoMessage ¶
func (*UpdateLinkedRootWitnessRaw) ProtoMessage()
func (*UpdateLinkedRootWitnessRaw) ProtoReflect ¶
func (x *UpdateLinkedRootWitnessRaw) ProtoReflect() protoreflect.Message
func (*UpdateLinkedRootWitnessRaw) Reset ¶
func (x *UpdateLinkedRootWitnessRaw) Reset()
func (*UpdateLinkedRootWitnessRaw) String ¶
func (x *UpdateLinkedRootWitnessRaw) String() string
type WitnessInfo ¶
type WitnessInfo struct { NetID string `protobuf:"bytes,1,opt,name=NetID,proto3" json:"NetID,omitempty"` // contains filtered or unexported fields }
func (*WitnessInfo) Descriptor
deprecated
func (*WitnessInfo) Descriptor() ([]byte, []int)
Deprecated: Use WitnessInfo.ProtoReflect.Descriptor instead.
func (*WitnessInfo) GetNetID ¶
func (x *WitnessInfo) GetNetID() string
func (*WitnessInfo) ProtoMessage ¶
func (*WitnessInfo) ProtoMessage()
func (*WitnessInfo) ProtoReflect ¶
func (x *WitnessInfo) ProtoReflect() protoreflect.Message
func (*WitnessInfo) Reset ¶
func (x *WitnessInfo) Reset()
func (*WitnessInfo) String ¶
func (x *WitnessInfo) String() string
type WitnessList ¶
type WitnessList struct { ActiveWitnessList []string `protobuf:"bytes,1,rep,name=activeWitnessList,proto3" json:"activeWitnessList,omitempty"` PendingWitnessList []string `protobuf:"bytes,2,rep,name=pendingWitnessList,proto3" json:"pendingWitnessList,omitempty"` PendingWitnessNumber int64 `protobuf:"varint,3,opt,name=pendingWitnessNumber,proto3" json:"pendingWitnessNumber,omitempty"` WitnessInfo []string `protobuf:"bytes,4,rep,name=witnessInfo,proto3" json:"witnessInfo,omitempty"` // contains filtered or unexported fields }
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) Descriptor
deprecated
func (*WitnessList) Descriptor() ([]byte, []int)
Deprecated: Use WitnessList.ProtoReflect.Descriptor instead.
func (*WitnessList) GetActiveWitnessList ¶
func (x *WitnessList) GetActiveWitnessList() []string
func (*WitnessList) GetPendingWitnessList ¶
func (x *WitnessList) GetPendingWitnessList() []string
func (*WitnessList) GetPendingWitnessNumber ¶
func (x *WitnessList) GetPendingWitnessNumber() int64
func (*WitnessList) GetWitnessInfo ¶
func (x *WitnessList) GetWitnessInfo() []string
func (*WitnessList) Pending ¶
func (wl *WitnessList) Pending() []string
Pending get pending witness list
func (*WitnessList) ProtoMessage ¶
func (*WitnessList) ProtoMessage()
func (*WitnessList) ProtoReflect ¶
func (x *WitnessList) ProtoReflect() protoreflect.Message
func (*WitnessList) Reset ¶
func (x *WitnessList) Reset()
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) String ¶
func (x *WitnessList) String() string
func (*WitnessList) UpdateInfo ¶
func (wl *WitnessList) UpdateInfo(mv database.IMultiValue, rules *version.Rules) error
UpdateInfo update pending witness list
type WitnessStatus ¶
type WitnessStatus struct { PendingList []string `json:"pendingList"` CurrentList []string `json:"currentList"` }
func GetWitnessStatusFromBlock ¶
func GetWitnessStatusFromBlock(b *block.Block) (*WitnessStatus, error)