block

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CertificateSignBytes

func CertificateSignBytes(blockHash hash.Hash, round int16) []byte

Types

type Block

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

func FromBytes

func FromBytes(data []byte) (*Block, error)

FromBytes constructs a new block from byte array.

func GenerateTestBlock

func GenerateTestBlock(proposer *crypto.Address, prevBlockHash *hash.Hash) *Block

GenerateTestBlock generates a block vote for testing.

func MakeBlock

func MakeBlock(version uint8, timestamp time.Time, txs Txs,
	prevBlockHash, stateRoot hash.Hash,
	prevCert *Certificate, sortitionSeed sortition.VerifiableSeed, proposer crypto.Address) *Block

func NewBlock

func NewBlock(header Header, prevCert *Certificate, txs Txs) *Block

func (*Block) Bytes

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

Bytes returns the serialized bytes for the Block. It caches the result so subsequent calls are more efficient.

func (*Block) Decode

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

func (*Block) Encode

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

Encode encodes the receiver to w.

func (*Block) Fingerprint

func (b *Block) Fingerprint() string

func (*Block) Hash

func (b *Block) Hash() hash.Hash

func (*Block) Header

func (b *Block) Header() *Header

func (*Block) MarshalCBOR

func (b *Block) MarshalCBOR() ([]byte, error)

func (*Block) PrevCertificate

func (b *Block) PrevCertificate() *Certificate

func (*Block) SanityCheck

func (b *Block) SanityCheck() error

func (*Block) SerializeSize

func (b *Block) SerializeSize() int

SerializeSize returns the number of bytes it would take to serialize the block.

func (*Block) Stamp

func (b *Block) Stamp() hash.Stamp

func (*Block) Transactions

func (b *Block) Transactions() Txs

func (*Block) UnmarshalCBOR

func (b *Block) UnmarshalCBOR(bs []byte) error

type Certificate

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

func GenerateTestCertificate

func GenerateTestCertificate(blockHash hash.Hash) *Certificate

func NewCertificate

func NewCertificate(round int16, committers, absentees []int32, signature *bls.Signature) *Certificate

func (*Certificate) Absentees

func (cert *Certificate) Absentees() []int32

func (*Certificate) Committers

func (cert *Certificate) Committers() []int32

func (*Certificate) Decode

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

func (*Certificate) Encode

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

Encode encodes the receiver to w.

func (*Certificate) Hash

func (cert *Certificate) Hash() hash.Hash

func (*Certificate) MarshalCBOR

func (cert *Certificate) MarshalCBOR() ([]byte, error)

func (*Certificate) Round

func (cert *Certificate) Round() int16

func (*Certificate) SanityCheck

func (cert *Certificate) SanityCheck() error

func (*Certificate) SerializeSize

func (cert *Certificate) SerializeSize() int

SerializeSize returns the number of bytes it would take to serialize the block.

func (*Certificate) Signature

func (cert *Certificate) Signature() *bls.Signature

func (*Certificate) UnmarshalCBOR

func (cert *Certificate) UnmarshalCBOR(bs []byte) error
type Header struct {
	// contains filtered or unexported fields
}

func NewHeader

func NewHeader(version uint8, time time.Time, stateRoot, prevBlockHash hash.Hash,
	sortitionSeed sortition.VerifiableSeed, proposerAddress crypto.Address) Header

func (*Header) Decode

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

func (*Header) Encode

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

Encode encodes the receiver to w.

func (*Header) PrevBlockHash

func (h *Header) PrevBlockHash() hash.Hash

PrevBlockHash returns the previous block hash

func (*Header) ProposerAddress

func (h *Header) ProposerAddress() crypto.Address

ProposerAddress returns the proposer address

func (*Header) SanityCheck

func (h *Header) SanityCheck() error

func (*Header) SerializeSize

func (h *Header) SerializeSize() int

SerializeSize returns the number of bytes it would take to serialize the header.

func (*Header) SortitionSeed

func (h *Header) SortitionSeed() sortition.VerifiableSeed

SortitionSeed returns the sortition seed

func (*Header) StateRoot

func (h *Header) StateRoot() hash.Hash

StateRoot returns the state root hash

func (*Header) Time

func (h *Header) Time() time.Time

Time returns the block time

func (*Header) UnixTime

func (h *Header) UnixTime() uint32

UnixTime returns the block time in Unix value

func (*Header) Version

func (h *Header) Version() uint8

Version returns the block version

type Txs

type Txs []*tx.Tx

func NewTxs

func NewTxs() Txs

func (*Txs) Append

func (txs *Txs) Append(trx *tx.Tx)

func (Txs) Get

func (txs Txs) Get(i int) *tx.Tx

func (Txs) IsEmpty

func (txs Txs) IsEmpty() bool

func (Txs) Len

func (txs Txs) Len() int

func (*Txs) Prepend

func (txs *Txs) Prepend(trx *tx.Tx)

func (*Txs) Remove

func (txs *Txs) Remove(i int)

func (Txs) Root

func (txs Txs) Root() hash.Hash

Jump to

Keyboard shortcuts

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