Documentation
¶
Index ¶
- Variables
- func ComputeHash(header Header, txs Txs, plan Plan, prevState State) id.Hash
- type Block
- func (block Block) Equal(other Block) bool
- func (block Block) Hash() id.Hash
- func (block Block) Header() Header
- func (block Block) MarshalBinary() ([]byte, error)
- func (block Block) MarshalJSON() ([]byte, error)
- func (block Block) Plan() Plan
- func (block Block) PreviousState() State
- func (block Block) String() string
- func (block Block) Txs() Txs
- func (block *Block) UnmarshalBinary(data []byte) error
- func (block *Block) UnmarshalJSON(data []byte) error
- type Blocks
- type Header
- func (header Header) BaseHash() id.Hash
- func (header Header) Height() Height
- func (header Header) Kind() Kind
- func (header Header) MarshalBinary() ([]byte, error)
- func (header Header) MarshalJSON() ([]byte, error)
- func (header Header) ParentHash() id.Hash
- func (header Header) PlanRef() id.Hash
- func (header Header) PrevStateRef() id.Hash
- func (header Header) Round() Round
- func (header Header) Signatories() id.Signatories
- func (header Header) String() string
- func (header Header) Timestamp() Timestamp
- func (header Header) TxsRef() id.Hash
- func (header *Header) UnmarshalBinary(data []byte) error
- func (header *Header) UnmarshalJSON(data []byte) error
- type Height
- type Kind
- type Plan
- type Round
- type State
- type Timestamp
- type Txs
Constants ¶
This section is empty.
Variables ¶
var ( InvalidHash = id.Hash{} InvalidSignature = id.Signature{} InvalidSignatory = id.Signatory{} InvalidBlock = Block{} InvalidRound = Round(-1) InvalidHeight = Height(-1) )
Define some default invalid values.
Functions ¶
Types ¶
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
A Block is the atomic unit upon which consensus is reached. Consensus guarantees a consistent ordering of Blocks that is agreed upon by all members in a distributed network, even when some of the members are malicious.
func New ¶
New Block with the Header, Txs, Plan, and State of the Block parent. The Block Hash will automatically be computed and set.
func (Block) Equal ¶
Equal compares one Block with another by checking that their Hashes are the equal, and their Notes are equal.
func (Block) MarshalBinary ¶ added in v0.2.0
MarshalBinary implements the `encoding.BinaryMarshaler` interface for the Block type.
func (Block) MarshalJSON ¶ added in v0.2.0
MarshalJSON implements the `json.Marshaler` interface for the Block type.
func (Block) PreviousState ¶ added in v0.2.0
PreviousState embedded in the Block for application-specific state after the execution of the Block parent.
func (*Block) UnmarshalBinary ¶ added in v0.2.0
UnmarshalBinary implements the `encoding.BinaryUnmarshaler` interface for the Block type.
func (*Block) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON implements the `json.Unmarshaler` interface for the Block type.
type Blocks ¶ added in v0.2.0
type Blocks []Block
Blocks defines a wrapper type around the []Block type.
type Header ¶ added in v0.2.0
type Header struct {
// contains filtered or unexported fields
}
A Header defines properties of a Block that are not application-specific. These properties are required by, or produced by, the consensus algorithm.
func NewHeader ¶ added in v0.2.0
func NewHeader(kind Kind, parentHash, baseHash, txsRef, planRef, prevStateRef id.Hash, height Height, round Round, timestamp Timestamp, signatories id.Signatories) Header
NewHeader returns a Header. It will panic if a pre-condition for Header validity is violated.
func (Header) MarshalBinary ¶ added in v0.2.0
MarshalBinary implements the `encoding.BinaryMarshaler` interface for the Header type.
func (Header) MarshalJSON ¶ added in v0.2.0
MarshalJSON implements the `json.Marshaler` interface for the Header type.
func (Header) ParentHash ¶ added in v0.2.0
ParentHash of the Block.
func (Header) PrevStateRef ¶ added in v0.3.0
PrevStateRef of the Block.
func (Header) Signatories ¶ added in v0.2.0
func (header Header) Signatories() id.Signatories
Signatories of the Block.
func (Header) String ¶ added in v0.2.0
String implements the `fmt.Stringer` interface for the Header type.
func (*Header) UnmarshalBinary ¶ added in v0.2.0
UnmarshalBinary implements the `encoding.BinaryUnmarshaler` interface for the Header type.
func (*Header) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON implements the `json.Unmarshaler` interface for the Header type.
type Kind ¶ added in v0.2.0
type Kind uint8
Kind defines the different kinds of Block that exist.
const ( // Invalid defines an invalid Kind that must not be used. Invalid Kind = iota // Standard Blocks are used when reaching consensus on the ordering of // application-specific data. Standard Blocks must have nil Header // Signatories. This is the most common Block Kind. Standard // Rebase Blocks are used when reaching consensus about a change to the // Header Signatories that oversee the consensus algorithm. Rebase Blocks // must include non-empty Header Signatories. Rebase // Base Blocks are used to finalise Rebase Blocks. Base Blocks must come // immediately after a Rebase Block, must have no Content, and must have the // same Header Signatories as their parent. Base )
type Plan ¶ added in v0.3.0
type Plan []byte
Plan stores application-specific plan data used in Blocks and Notes (must be nil in Rebase Blocks and Base Blocks).
type State ¶ added in v0.2.0
type State []byte
State stores application-specific state after the execution of a Block.
type Timestamp ¶ added in v0.2.0
type Timestamp uint64
Timestamp represents seconds since Unix Epoch.