block

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package block implements the roothash block and header.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

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

Block is an Oasis block.

Keep this in sync with /runtime/src/consensus/roothash/block.rs.

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 Timestamp `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"`

	// MessagesHash is the hash of emitted runtime messages.
	MessagesHash hash.Hash `json:"messages_hash"`

	// InMessagesHash is the hash of processed incoming messages.
	InMessagesHash hash.Hash `json:"in_msgs_hash"`
}

Header is a block header.

Keep this in sync with /runtime/src/consensus/roothash/block.rs.

type HeaderType

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 Timestamp

type Timestamp uint64

Timestamp is a custom time stamp type that encodes like time.Time when marshaling to text.

func (Timestamp) MarshalText

func (ts Timestamp) MarshalText() ([]byte, error)

MarshalText encodes a Timestamp to text by converting it from Unix time to local time.

func (*Timestamp) UnmarshalText

func (ts *Timestamp) UnmarshalText(data []byte) error

UnmarshalText decodes a text slice into a Timestamp.

Jump to

Keyboard shortcuts

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