types

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2019 License: LGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const GenesisHeight uint64 = 1

GenesisHeight refers to the initial height the genesis block should be.

Variables

View Source
var NullBlockHash common.Hash

NullBlockHash is the blockHash for ⊥ value.

View Source
var SkipBlockHash common.Hash

SkipBlockHash is the blockHash for SKIP value.

Functions

This section is empty.

Types

type AgreementResult

type AgreementResult struct {
	BlockHash    common.Hash `json:"block_hash"`
	Position     Position    `json:"position"`
	Votes        []Vote      `json:"votes"`
	IsEmptyBlock bool        `json:"is_empty_block"`
	Randomness   []byte      `json:"randomness"`
}

AgreementResult describes an agremeent result.

func (*AgreementResult) String

func (r *AgreementResult) String() string

type Block

type Block struct {
	ProposerID  NodeID           `json:"proposer_id"`
	ParentHash  common.Hash      `json:"parent_hash"`
	Hash        common.Hash      `json:"hash"`
	Position    Position         `json:"position"`
	Timestamp   time.Time        `json:"timestamp"`
	Payload     []byte           `json:"payload"`
	PayloadHash common.Hash      `json:"payload_hash"`
	Witness     Witness          `json:"witness"`
	Randomness  []byte           `json:"randomness"`
	Signature   crypto.Signature `json:"signature"`

	CRSSignature crypto.Signature `json:"crs_signature"`
}

Block represents a single event broadcasted on the network.

func (*Block) Clone

func (b *Block) Clone() (bcopy *Block)

Clone returns a deep copy of a block.

func (*Block) DecodeRLP

func (b *Block) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder

func (*Block) EncodeRLP

func (b *Block) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder

func (*Block) IsEmpty

func (b *Block) IsEmpty() bool

IsEmpty checks if the block is an 'empty block'.

func (*Block) IsFinalized

func (b *Block) IsFinalized() bool

IsFinalized checks if the block is finalized.

func (*Block) IsGenesis

func (b *Block) IsGenesis() bool

IsGenesis checks if the block is a genesisBlock

func (*Block) String

func (b *Block) String() string

type BlockVerifyStatus

type BlockVerifyStatus int

BlockVerifyStatus is the return code for core.Application.VerifyBlock

const (
	// VerifyOK: Block is verified.
	VerifyOK BlockVerifyStatus = iota
	// VerifyRetryLater: Block is unable to be verified at this moment.
	// Try again later.
	VerifyRetryLater
	// VerifyInvalidBlock: Block is an invalid one.
	VerifyInvalidBlock
)

Enums for return value of core.Application.VerifyBlock.

type BlocksByPosition

type BlocksByPosition []*Block

BlocksByPosition is the helper type for sorting slice of blocks by position.

func (BlocksByPosition) Len

func (bs BlocksByPosition) Len() int

Len implements Len method in sort.Sort interface.

func (BlocksByPosition) Less

func (bs BlocksByPosition) Less(i int, j int) bool

Less implements Less method in sort.Sort interface.

func (*BlocksByPosition) Pop

func (bs *BlocksByPosition) Pop() (ret interface{})

Pop implements Pop method in heap interface.

func (*BlocksByPosition) Push

func (bs *BlocksByPosition) Push(x interface{})

Push implements Push method in heap interface.

func (BlocksByPosition) Swap

func (bs BlocksByPosition) Swap(i int, j int)

Swap implements Swap method in sort.Sort interface.

type ByHash

type ByHash []*Block

ByHash is the helper type for sorting slice of blocks by hash.

func (ByHash) Len

func (b ByHash) Len() int

func (ByHash) Less

func (b ByHash) Less(i int, j int) bool

func (ByHash) Swap

func (b ByHash) Swap(i int, j int)

type Config

type Config struct {
	// Lambda related.
	LambdaBA  time.Duration
	LambdaDKG time.Duration

	// Set related.
	NotarySetSize uint32

	// Time related.
	RoundLength      uint64
	MinBlockInterval time.Duration
}

Config stands for Current Configuration Parameters.

func (*Config) Bytes

func (c *Config) Bytes() []byte

Bytes returns []byte representation of Config.

func (*Config) Clone

func (c *Config) Clone() *Config

Clone return a copied configuration.

type Msg

type Msg struct {
	PeerID  interface{}
	Payload interface{}
}

Msg for the network ReceiveChan.

type NodeID

type NodeID struct {
	common.Hash
}

NodeID is the ID type for nodes.

func NewNodeID

func NewNodeID(pubKey crypto.PublicKey) NodeID

NewNodeID returns a NodeID with Hash set to the hash value of public key.

func (NodeID) Equal

func (v NodeID) Equal(v2 NodeID) bool

Equal checks if the hash representation is the same NodeID.

func (NodeID) String

func (v NodeID) String() string

type NodeIDs

type NodeIDs []NodeID

NodeIDs implements sort.Interface for NodeID.

func (NodeIDs) Len

func (v NodeIDs) Len() int

func (NodeIDs) Less

func (v NodeIDs) Less(i int, j int) bool

func (NodeIDs) Swap

func (v NodeIDs) Swap(i int, j int)

type NodeSet

type NodeSet struct {
	IDs map[NodeID]struct{}
}

NodeSet is the node set structure as defined in DEXON consensus core.

func NewNodeSet

func NewNodeSet() *NodeSet

NewNodeSet creates a new NodeSet instance.

func NewNodeSetFromMap

func NewNodeSetFromMap(nodes map[NodeID]struct{}) *NodeSet

NewNodeSetFromMap creates a new NodeSet from NodeID map.

func (*NodeSet) Add

func (ns *NodeSet) Add(ID NodeID)

Add a NodeID to the set.

func (*NodeSet) Clone

func (ns *NodeSet) Clone() *NodeSet

Clone the NodeSet.

func (*NodeSet) GetSubSet

func (ns *NodeSet) GetSubSet(
	size int, target *SubSetTarget) map[NodeID]struct{}

GetSubSet returns the subset of given target.

type Position

type Position struct {
	Round  uint64 `json:"round"`
	Height uint64 `json:"height"`
}

Position describes the position in the block lattice of an entity.

func (Position) Equal

func (pos Position) Equal(other Position) bool

Equal checks if two positions are equal.

func (Position) Newer

func (pos Position) Newer(other Position) bool

Newer checks if one block is newer than another one on the same chain. If two blocks on different chain compared by this function, it would panic.

func (Position) Older

func (pos Position) Older(other Position) bool

Older checks if one block is older than another one on the same chain. If two blocks on different chain compared by this function, it would panic.

func (Position) String

func (pos Position) String() string

type SubSetTarget

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

SubSetTarget is the sub set target for GetSubSet().

func NewNodeLeaderTarget

func NewNodeLeaderTarget(crs common.Hash, height uint64) *SubSetTarget

NewNodeLeaderTarget is the target for getting leader of fast BA.

func NewNotarySetTarget

func NewNotarySetTarget(crs common.Hash) *SubSetTarget

NewNotarySetTarget is the target for getting Notary Set.

type Vote

type Vote struct {
	VoteHeader       `json:"header"`
	PartialSignature cryptoDKG.PartialSignature `json:"partial_signature"`
	Signature        crypto.Signature           `json:"signature"`
}

Vote is the vote structure defined in Crypto Shuffle Algorithm.

func NewVote

func NewVote(t VoteType, hash common.Hash, period uint64) *Vote

NewVote constructs a Vote instance with header fields.

func (*Vote) Clone

func (v *Vote) Clone() *Vote

Clone returns a deep copy of a vote.

func (*Vote) String

func (v *Vote) String() string

type VoteHeader

type VoteHeader struct {
	ProposerID NodeID      `json:"proposer_id"`
	Type       VoteType    `json:"type"`
	BlockHash  common.Hash `json:"block_hash"`
	Period     uint64      `json:"period"`
	Position   Position    `json:"position"`
}

VoteHeader is the header for vote, which can be used as map keys.

type VoteType

type VoteType byte

VoteType is the type of vote.

const (
	VoteInit VoteType = iota
	VotePreCom
	VoteCom
	VoteFast
	VoteFastCom
	// Do not add any type below MaxVoteType.
	MaxVoteType
)

VoteType enum.

type Witness

type Witness struct {
	Height uint64 `json:"height"`
	Data   []byte `json:"data"`
}

Witness represents the consensus information on the compaction chain.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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