Documentation ¶
Index ¶
- type Block
- type BlockChain
- func (bc *BlockChain) AddBlock(block *Block)
- func (bc *BlockChain) AddVote(vote *Vote) (bool, *QC)
- func (bc *BlockChain) CommitBlock(id crypto.Identifier, view types.View) ([]*Block, []*Block, error)
- func (bc *BlockChain) Exists(id crypto.Identifier) bool
- func (bc *BlockChain) GetBlockByID(id crypto.Identifier) (*Block, error)
- func (bc *BlockChain) GetBlockByView(view types.View) *Block
- func (bc *BlockChain) GetBlockIntervals() float64
- func (bc *BlockChain) GetChainGrowth() float64
- func (bc *BlockChain) GetChildrenBlocks(id crypto.Identifier) []*Block
- func (bc *BlockChain) GetCommittedBlocks() int
- func (bc *BlockChain) GetGrandParentBlock(id crypto.Identifier) (*Block, error)
- func (bc *BlockChain) GetHighestCommitted() int
- func (bc *BlockChain) GetParentBlock(id crypto.Identifier) (*Block, error)
- type BlockContainer
- type LevelledForest
- func (f *LevelledForest) AddVertex(vertex Vertex)
- func (f *LevelledForest) GetChildren(id crypto.Identifier) VertexIterator
- func (f *LevelledForest) GetNumberOfChildren(id crypto.Identifier) int
- func (f *LevelledForest) GetNumberOfVerticesAtLevel(level uint64) int
- func (f *LevelledForest) GetVertex(id crypto.Identifier) (Vertex, bool)
- func (f *LevelledForest) GetVerticesAtLevel(level uint64) VertexIterator
- func (f *LevelledForest) HasVertex(id crypto.Identifier) bool
- func (f *LevelledForest) PruneUpToLevel(level uint64) ([]*Block, int, error)
- func (f *LevelledForest) VerifyVertex(vertex Vertex) error
- type QC
- type Quorum
- type Vertex
- type VertexIterator
- type VertexList
- type VertexSet
- type Vote
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
type BlockChain ¶
type BlockChain struct {
// contains filtered or unexported fields
}
func NewBlockchain ¶
func NewBlockchain(n int) *BlockChain
func (*BlockChain) AddBlock ¶
func (bc *BlockChain) AddBlock(block *Block)
func (*BlockChain) CommitBlock ¶
func (bc *BlockChain) CommitBlock(id crypto.Identifier, view types.View) ([]*Block, []*Block, error)
CommitBlock prunes blocks and returns committed blocks up to the last committed one and prunedBlocks
func (*BlockChain) Exists ¶
func (bc *BlockChain) Exists(id crypto.Identifier) bool
func (*BlockChain) GetBlockByID ¶
func (bc *BlockChain) GetBlockByID(id crypto.Identifier) (*Block, error)
func (*BlockChain) GetBlockByView ¶
func (bc *BlockChain) GetBlockByView(view types.View) *Block
func (*BlockChain) GetBlockIntervals ¶
func (bc *BlockChain) GetBlockIntervals() float64
func (*BlockChain) GetChainGrowth ¶
func (bc *BlockChain) GetChainGrowth() float64
func (*BlockChain) GetChildrenBlocks ¶
func (bc *BlockChain) GetChildrenBlocks(id crypto.Identifier) []*Block
func (*BlockChain) GetCommittedBlocks ¶
func (bc *BlockChain) GetCommittedBlocks() int
func (*BlockChain) GetGrandParentBlock ¶
func (bc *BlockChain) GetGrandParentBlock(id crypto.Identifier) (*Block, error)
func (*BlockChain) GetHighestCommitted ¶
func (bc *BlockChain) GetHighestCommitted() int
func (*BlockChain) GetParentBlock ¶
func (bc *BlockChain) GetParentBlock(id crypto.Identifier) (*Block, error)
type BlockContainer ¶
type BlockContainer struct {
Block *Block
}
BlockContainer wraps a block to implement forest.Vertex In addition, it holds some additional properties for efficient processing of blocks by the Finalizer
func (*BlockContainer) GetBlock ¶
func (b *BlockContainer) GetBlock() *Block
func (*BlockContainer) Level ¶
func (b *BlockContainer) Level() uint64
func (*BlockContainer) Parent ¶
func (b *BlockContainer) Parent() (crypto.Identifier, uint64)
func (*BlockContainer) VertexID ¶
func (b *BlockContainer) VertexID() crypto.Identifier
functions implementing forest.vertex
type LevelledForest ¶
type LevelledForest struct { LowestLevel uint64 // contains filtered or unexported fields }
LevelledForest contains multiple trees (which is a potentially disconnected planar graph). Each vertexContainer in the graph has a level (view) and a hash. A vertexContainer can only have one parent with strictly smaller level (view). A vertexContainer can have multiple children, all with strictly larger level (view). A LevelledForest provides the ability to prune all vertices up to a specific level. A tree whose root is below the pruning threshold might decompose into multiple disconnected subtrees as a result of pruning.
func NewLevelledForest ¶
func NewLevelledForest() *LevelledForest
NewLevelledForest initializes a LevelledForest
func (*LevelledForest) AddVertex ¶
func (f *LevelledForest) AddVertex(vertex Vertex)
AddVertex adds vertex to forest if vertex is within non-pruned levels Handles repeated addition of same vertex (keeps first added vertex). If vertex is at or below pruning level: method is NoOp. UNVALIDATED: requires that vertex would pass validity check LevelledForest.VerifyVertex(vertex).
func (*LevelledForest) GetChildren ¶
func (f *LevelledForest) GetChildren(id crypto.Identifier) VertexIterator
GetChildren returns a VertexIterator to iterate over the children An empty VertexIterator is returned, if no vertices are known whose parent is `id` , `level`
func (*LevelledForest) GetNumberOfChildren ¶
func (f *LevelledForest) GetNumberOfChildren(id crypto.Identifier) int
GetVerticesAtLevel returns a VertexIterator to iterate over the Vertices at the specified height
func (*LevelledForest) GetNumberOfVerticesAtLevel ¶
func (f *LevelledForest) GetNumberOfVerticesAtLevel(level uint64) int
GetVerticesAtLevel returns a VertexIterator to iterate over the Vertices at the specified height
func (*LevelledForest) GetVertex ¶
func (f *LevelledForest) GetVertex(id crypto.Identifier) (Vertex, bool)
GetVertex returns (<full vertex>, true) if the vertex with `id` and `level` was found (nil, false) if full vertex is unknown
func (*LevelledForest) GetVerticesAtLevel ¶
func (f *LevelledForest) GetVerticesAtLevel(level uint64) VertexIterator
GetVerticesAtLevel returns a VertexIterator to iterate over the Vertices at the specified height An empty VertexIterator is returned, if no vertices are known at the specified `level`
func (*LevelledForest) HasVertex ¶
func (f *LevelledForest) HasVertex(id crypto.Identifier) bool
HasVertex returns true iff full vertex exists
func (*LevelledForest) PruneUpToLevel ¶
func (f *LevelledForest) PruneUpToLevel(level uint64) ([]*Block, int, error)
PruneUpToLevel prunes all blocks UP TO but NOT INCLUDING `level`
func (*LevelledForest) VerifyVertex ¶
func (f *LevelledForest) VerifyVertex(vertex Vertex) error
VerifyVertex verifies that vertex satisfies the following conditions (1)
type Vertex ¶
type Vertex interface { // VertexID returns the vertex's ID (in most cases its hash) VertexID() crypto.Identifier // Level returns the vertex's level Level() uint64 // Parent returns the returns the parents (level, ID) Parent() (crypto.Identifier, uint64) // GetBlock returns the block contained in vertex GetBlock() *Block }
type VertexIterator ¶
type VertexIterator struct {
// contains filtered or unexported fields
}
VertexIterator is a stateful iterator for VertexList. Internally operates directly on the Vertex Containers It has one-element look ahead for skipping empty vertex containers.
func (*VertexIterator) HasNext ¶
func (it *VertexIterator) HasNext() bool
HasNext returns true if and only if there is a next Vertex
func (*VertexIterator) NextVertex ¶
func (it *VertexIterator) NextVertex() Vertex
NextVertex returns the next Vertex or nil if there is none
type VertexList ¶
type VertexList []*vertexContainer
type VertexSet ¶
type VertexSet map[crypto.Identifier]*vertexContainer