block

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HeaderHashSize size of a block header hash in bytes
	HeaderHashSize = 32
	// HeightSize size of a block height field in bytes
	HeightSize = 8
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Header *Header
	Txs    []transactions.Transaction
}

Block defines a block on the Dusk blockchain.

func NewBlock

func NewBlock() *Block

NewBlock will return an empty Block with an empty BlockHeader.

func (*Block) AddTx

func (b *Block) AddTx(tx transactions.Transaction)

AddTx will add a transaction to the block.

func (*Block) Clear

func (b *Block) Clear()

Clear will empty out all the block's fields.

func (*Block) Decode

func (b *Block) Decode(r io.Reader) error

Decode a Block struct from r into b.

func (*Block) Encode

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

Encode a Block struct and write to w.

func (*Block) Equals

func (b *Block) Equals(other *Block) bool

Equals returns true if two blocks are equal

func (*Block) SetHash

func (b *Block) SetHash() error

SetHash will set the block hash.

func (*Block) SetPrevBlock

func (b *Block) SetPrevBlock(prevHeader *Header)

SetPrevBlock will set all the previous block hash field from a header.

func (*Block) SetRoot

func (b *Block) SetRoot() error

SetRoot will set the block merkle root hash.

type Certificate

type Certificate struct {
	StepOneBatchedSig []byte // Batched BLS signature of the block reduction phase (33 bytes)
	StepTwoBatchedSig []byte
	Step              uint8  // Step the agreement terminated at (1 byte)
	StepOneCommittee  uint64 // Binary representation of the committee members who voted in favor of this block (8 bytes)
	StepTwoCommittee  uint64
}

Certificate defines a block certificate made as a result from the consensus.

func EmptyCertificate

func EmptyCertificate() *Certificate

func (*Certificate) Decode

func (c *Certificate) Decode(r io.Reader) error

Decode a Certificate struct from r into c.

func (*Certificate) Encode

func (c *Certificate) Encode(w io.Writer) error

Encode a Certificate struct and write to w.

func (*Certificate) Equals

func (c *Certificate) Equals(other *Certificate) bool

Equals returns true if both certificates are equal

type Header struct {
	Version   uint8  // Block version byte
	Height    uint64 // Block height
	Timestamp int64  // Block timestamp

	PrevBlockHash []byte // Hash of previous block (32 bytes)
	Seed          []byte // Marshaled BLS signature or hash of the previous block seed (32 bytes)
	TxRoot        []byte // Root hash of the merkle tree containing all txes (32 bytes)

	*Certificate        // Block certificate
	Hash         []byte // Hash of all previous fields
}

Header defines a block header on a Dusk block.

func (*Header) Bytes

func (b *Header) Bytes() ([]byte, error)

Bytes returns the block header, encoded as a slice of bytes.

func (*Header) Decode

func (b *Header) Decode(r io.Reader) error

Decode a Header struct from r into b.

func (*Header) Encode

func (b *Header) Encode(w io.Writer) error

Encode a Header struct and write to w.

func (*Header) EncodeHashable

func (b *Header) EncodeHashable(w io.Writer) error

EncodeHashable will encode all the fields needed from a Header to create a block hash. Result will be written to w.

func (*Header) Equals

func (b *Header) Equals(other *Header) bool

Equals returns true if headers are equal

func (*Header) SetHash

func (b *Header) SetHash() error

SetHash will set this block header's hash by encoding all the relevant fields and then hashing the result.

Jump to

Keyboard shortcuts

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