block

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicCheckError added in v0.15.0

type BasicCheckError struct {
	Reason string
}

BasicCheckError is returned when the basic check on the certificate fails.

func (BasicCheckError) Error added in v0.15.0

func (e BasicCheckError) Error() string

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 MakeBlock

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

func NewBlock

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

func (*Block) BasicCheck added in v0.15.0

func (b *Block) BasicCheck() error

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

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.Certificate

func (*Block) SerializeSize

func (b *Block) SerializeSize() int

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

func (*Block) String added in v0.15.0

func (b *Block) String() string

func (*Block) Transactions

func (b *Block) Transactions() Txs

func (*Block) UnmarshalCBOR

func (b *Block) 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) BasicCheck added in v0.15.0

func (h *Header) BasicCheck() error

func (*Header) Decode

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

func (*Header) Encode

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

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) 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