blockcache

package
v0.0.0-...-5fdeb2f Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2020 License: LGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DelSingleBlockTime ...
	DelSingleBlockTime int64 = 10
)

Variables

View Source
var BcMessageType_name = map[int32]string{
	0: "LinkType",
	1: "UpdateActiveType",
	2: "UpdateLinkedRootWitnessType",
}
View Source
var BcMessageType_value = map[string]int32{
	"LinkType":                    0,
	"UpdateActiveType":            1,
	"UpdateLinkedRootWitnessType": 2,
}
View Source
var (
	BlockCacheWALDir = "./BlockCacheWAL"
)

The directory of block cache wal.

Functions

This section is empty.

Types

type BCNType

type BCNType int

BCNType type of BlockCacheNode

const (
	Linked BCNType = iota
	Single
)

The types of BlockCacheNode

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"`
	XXX_NoUnkeyedLiteral struct{}      `json:"-"`
	XXX_unrecognized     []byte        `json:"-"`
	XXX_sizecache        int32         `json:"-"`
}

func (*BcMessage) Descriptor

func (*BcMessage) Descriptor() ([]byte, []int)

func (*BcMessage) GetData

func (m *BcMessage) GetData() []byte

func (*BcMessage) GetType

func (m *BcMessage) GetType() BcMessageType

func (*BcMessage) ProtoMessage

func (*BcMessage) ProtoMessage()

func (*BcMessage) Reset

func (m *BcMessage) Reset()

func (*BcMessage) String

func (m *BcMessage) String() string

func (*BcMessage) XXX_DiscardUnknown

func (m *BcMessage) XXX_DiscardUnknown()

func (*BcMessage) XXX_Marshal

func (m *BcMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*BcMessage) XXX_Merge

func (m *BcMessage) XXX_Merge(src proto.Message)

func (*BcMessage) XXX_Size

func (m *BcMessage) XXX_Size() int

func (*BcMessage) XXX_Unmarshal

func (m *BcMessage) XXX_Unmarshal(b []byte) error

type BcMessageType

type BcMessageType int32
const (
	BcMessageType_LinkType                    BcMessageType = 0
	BcMessageType_UpdateActiveType            BcMessageType = 1
	BcMessageType_UpdateLinkedRootWitnessType BcMessageType = 2
)

func (BcMessageType) EnumDescriptor

func (BcMessageType) EnumDescriptor() ([]byte, []int)

func (BcMessageType) String

func (x BcMessageType) String() string

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 (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"`
	XXX_NoUnkeyedLiteral struct{}     `json:"-"`
	XXX_unrecognized     []byte       `json:"-"`
	XXX_sizecache        int32        `json:"-"`
}

func (*BlockCacheRaw) Descriptor

func (*BlockCacheRaw) Descriptor() ([]byte, []int)

func (*BlockCacheRaw) GetBlockBytes

func (m *BlockCacheRaw) GetBlockBytes() []byte

func (*BlockCacheRaw) GetSerialNum

func (m *BlockCacheRaw) GetSerialNum() int64

func (*BlockCacheRaw) GetWitnessList

func (m *BlockCacheRaw) GetWitnessList() *WitnessList

func (*BlockCacheRaw) ProtoMessage

func (*BlockCacheRaw) ProtoMessage()

func (*BlockCacheRaw) Reset

func (m *BlockCacheRaw) Reset()

func (*BlockCacheRaw) String

func (m *BlockCacheRaw) String() string

func (*BlockCacheRaw) XXX_DiscardUnknown

func (m *BlockCacheRaw) XXX_DiscardUnknown()

func (*BlockCacheRaw) XXX_Marshal

func (m *BlockCacheRaw) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*BlockCacheRaw) XXX_Merge

func (m *BlockCacheRaw) XXX_Merge(src proto.Message)

func (*BlockCacheRaw) XXX_Size

func (m *BlockCacheRaw) XXX_Size() int

func (*BlockCacheRaw) XXX_Unmarshal

func (m *BlockCacheRaw) XXX_Unmarshal(b []byte) error

type CacheStatus

type CacheStatus int

CacheStatus ...

type ConAlgo

type ConAlgo interface {
	Add(*block.Block, bool, bool) error
}

ConAlgo ...

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"`
	XXX_NoUnkeyedLiteral struct{}     `json:"-"`
	XXX_unrecognized     []byte       `json:"-"`
	XXX_sizecache        int32        `json:"-"`
}

func (*UpdateActiveRaw) Descriptor

func (*UpdateActiveRaw) Descriptor() ([]byte, []int)

func (*UpdateActiveRaw) GetBlockHashBytes

func (m *UpdateActiveRaw) GetBlockHashBytes() []byte

func (*UpdateActiveRaw) GetWitnessList

func (m *UpdateActiveRaw) GetWitnessList() *WitnessList

func (*UpdateActiveRaw) ProtoMessage

func (*UpdateActiveRaw) ProtoMessage()

func (*UpdateActiveRaw) Reset

func (m *UpdateActiveRaw) Reset()

func (*UpdateActiveRaw) String

func (m *UpdateActiveRaw) String() string

func (*UpdateActiveRaw) XXX_DiscardUnknown

func (m *UpdateActiveRaw) XXX_DiscardUnknown()

func (*UpdateActiveRaw) XXX_Marshal

func (m *UpdateActiveRaw) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UpdateActiveRaw) XXX_Merge

func (m *UpdateActiveRaw) XXX_Merge(src proto.Message)

func (*UpdateActiveRaw) XXX_Size

func (m *UpdateActiveRaw) XXX_Size() int

func (*UpdateActiveRaw) XXX_Unmarshal

func (m *UpdateActiveRaw) XXX_Unmarshal(b []byte) error

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"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*UpdateLinkedRootWitnessRaw) Descriptor

func (*UpdateLinkedRootWitnessRaw) Descriptor() ([]byte, []int)

func (*UpdateLinkedRootWitnessRaw) GetBlockHashBytes

func (m *UpdateLinkedRootWitnessRaw) GetBlockHashBytes() []byte

func (*UpdateLinkedRootWitnessRaw) GetLinkedRootWitness

func (m *UpdateLinkedRootWitnessRaw) GetLinkedRootWitness() []string

func (*UpdateLinkedRootWitnessRaw) ProtoMessage

func (*UpdateLinkedRootWitnessRaw) ProtoMessage()

func (*UpdateLinkedRootWitnessRaw) Reset

func (m *UpdateLinkedRootWitnessRaw) Reset()

func (*UpdateLinkedRootWitnessRaw) String

func (m *UpdateLinkedRootWitnessRaw) String() string

func (*UpdateLinkedRootWitnessRaw) XXX_DiscardUnknown

func (m *UpdateLinkedRootWitnessRaw) XXX_DiscardUnknown()

func (*UpdateLinkedRootWitnessRaw) XXX_Marshal

func (m *UpdateLinkedRootWitnessRaw) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UpdateLinkedRootWitnessRaw) XXX_Merge

func (m *UpdateLinkedRootWitnessRaw) XXX_Merge(src proto.Message)

func (*UpdateLinkedRootWitnessRaw) XXX_Size

func (m *UpdateLinkedRootWitnessRaw) XXX_Size() int

func (*UpdateLinkedRootWitnessRaw) XXX_Unmarshal

func (m *UpdateLinkedRootWitnessRaw) XXX_Unmarshal(b []byte) error

type WitnessInfo

type WitnessInfo struct {
	NetID                string   `protobuf:"bytes,1,opt,name=NetID,proto3" json:"NetID,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*WitnessInfo) Descriptor

func (*WitnessInfo) Descriptor() ([]byte, []int)

func (*WitnessInfo) GetNetID

func (m *WitnessInfo) GetNetID() string

func (*WitnessInfo) ProtoMessage

func (*WitnessInfo) ProtoMessage()

func (*WitnessInfo) Reset

func (m *WitnessInfo) Reset()

func (*WitnessInfo) String

func (m *WitnessInfo) String() string

func (*WitnessInfo) XXX_DiscardUnknown

func (m *WitnessInfo) XXX_DiscardUnknown()

func (*WitnessInfo) XXX_Marshal

func (m *WitnessInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*WitnessInfo) XXX_Merge

func (m *WitnessInfo) XXX_Merge(src proto.Message)

func (*WitnessInfo) XXX_Size

func (m *WitnessInfo) XXX_Size() int

func (*WitnessInfo) XXX_Unmarshal

func (m *WitnessInfo) XXX_Unmarshal(b []byte) error

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"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

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

func (*WitnessList) Descriptor() ([]byte, []int)

func (*WitnessList) GetActiveWitnessList

func (m *WitnessList) GetActiveWitnessList() []string

func (*WitnessList) GetPendingWitnessList

func (m *WitnessList) GetPendingWitnessList() []string

func (*WitnessList) GetPendingWitnessNumber

func (m *WitnessList) GetPendingWitnessNumber() int64

func (*WitnessList) GetWitnessInfo

func (m *WitnessList) GetWitnessInfo() []string

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) ProtoMessage

func (*WitnessList) ProtoMessage()

func (*WitnessList) Reset

func (m *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 (m *WitnessList) String() string

func (*WitnessList) UpdateInfo

func (wl *WitnessList) UpdateInfo(mv db.MVCCDB, rules *version.Rules) error

UpdateInfo update pending witness list

func (*WitnessList) UpdatePending

func (wl *WitnessList) UpdatePending(mv db.MVCCDB, rules *version.Rules) error

UpdatePending update pending witness list

func (*WitnessList) XXX_DiscardUnknown

func (m *WitnessList) XXX_DiscardUnknown()

func (*WitnessList) XXX_Marshal

func (m *WitnessList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*WitnessList) XXX_Merge

func (m *WitnessList) XXX_Merge(src proto.Message)

func (*WitnessList) XXX_Size

func (m *WitnessList) XXX_Size() int

func (*WitnessList) XXX_Unmarshal

func (m *WitnessList) XXX_Unmarshal(b []byte) error

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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