oasis-core: github.com/oasislabs/oasis-core/go/roothash/api/block Index | Files

package block

import "github.com/oasislabs/oasis-core/go/roothash/api/block"

Package block implements the roothash block and header.

Index

Package Files

block.go header.go message.go

Variables

var ErrInvalidVersion = errors.New("roothash: invalid version")

ErrInvalidVersion is the error returned when a version is invalid.

type Block Uses

type Block struct {
    // Header is the block header.
    Header Header `json:"header"`
}

Block is an Oasis block.

Keep this in sync with /runtime/src/common/roothash.rs.

func NewEmptyBlock Uses

func NewEmptyBlock(child *Block, timestamp uint64, htype HeaderType) *Block

NewEmptyBlock creates a new empty block with a specific type.

func NewGenesisBlock Uses

func NewGenesisBlock(id common.Namespace, timestamp uint64) *Block

NewGenesisBlock creates a new empty genesis block given a runtime id and POSIX timestamp.

type Header struct {
    // Version is the protocol version number.
    Version uint16 `json:"version"`

    // Namespace is the header's chain namespace.
    Namespace common.Namespace `json:"namespace"`

    // Round is the block round.
    Round uint64 `json:"round"`

    // Timestamp is the block timestamp (POSIX time).
    Timestamp uint64 `json:"timestamp"`

    // HeaderType is the header type.
    HeaderType HeaderType `json:"header_type"`

    // PreviousHash is the previous block hash.
    PreviousHash hash.Hash `json:"previous_hash"`

    // IORoot is the I/O merkle root.
    IORoot hash.Hash `json:"io_root"`

    // StateRoot is the state merkle root.
    StateRoot hash.Hash `json:"state_root"`

    // Messages are the roothash messages sent in this round.
    Messages []*Message `json:"messages"`

    // StorageSignatures are the storage receipt signatures for the merkle
    // roots.
    StorageSignatures []signature.Signature `json:"storage_signatures"`
}

Header is a block header.

Keep this in sync with /runtime/src/common/roothash.rs.

func (*Header) EncodedHash Uses

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

EncodedHash returns the encoded cryptographic hash of the header.

func (*Header) IsParentOf Uses

func (h *Header) IsParentOf(child *Header) bool

IsParentOf returns true iff the header is the parent of a child header.

func (*Header) MostlyEqual Uses

func (h *Header) MostlyEqual(cmp *Header) bool

MostlyEqual compares vs another header for equality, omitting the StorageSignatures field as it is not universally guaranteed to be present.

Locations where this matter should do the comparison manually.

func (*Header) RootsForStorageReceipt Uses

func (h *Header) RootsForStorageReceipt() []hash.Hash

RootsForStorageReceipt gets the merkle roots that must be part of a storage receipt.

func (*Header) StorageRoots Uses

func (h *Header) StorageRoots() (roots []storage.Root)

StorageRoots returns the storage roots contained in this header.

func (*Header) VerifyStorageReceipt Uses

func (h *Header) VerifyStorageReceipt(receipt *storage.ReceiptBody) error

VerifyStorageReceipt validates that the provided storage receipt matches the header.

func (*Header) VerifyStorageReceiptSignatures Uses

func (h *Header) VerifyStorageReceiptSignatures() error

VerifyStorageReceiptSignatures validates that the storage receipt signatures match the signatures for the current merkle roots.

Note: Ensuring that the signatures are signed by keypair(s) that are expected is the responsibility of the caller.

type HeaderType Uses

type HeaderType uint8

HeaderType is the type of header.

const (
    // Invalid is an invalid header type and should never be stored.
    Invalid HeaderType = 0

    // Normal is a normal header.
    Normal HeaderType = 1

    // RoundFailed is a header resulting from a failed round. Such a
    // header contains no transactions but advances the round as normal
    // to prevent replays of old commitments.
    RoundFailed HeaderType = 2

    // EpochTransition is a header resulting from an epoch transition.
    //
    // Such a header contains no transactions but advances the round as
    // normal.
    // TODO: Consider renaming this to CommitteeTransition.
    EpochTransition HeaderType = 3

    // Suspended is a header resulting from the runtime being suspended.
    //
    // Such a header contains no transactions but advances the round as
    // normal.
    Suspended HeaderType = 4
)

type Message Uses

type Message struct {
}

Message is a roothash message that can be sent by a runtime.

Package block imports 7 packages (graph) and is imported by 21 packages. Updated 2020-05-29. Refresh now. Tools for package owners.