block

package
v1.14.1-db-metrics-fix Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: BSD-3-Clause Imports: 13 Imported by: 24

Documentation

Index

Constants

View Source
const CodecVersion = 0

Variables

Functions

This section is empty.

Types

type Block

type Block interface {
	ID() ids.ID
	ParentID() ids.ID
	Block() []byte
	Bytes() []byte
	// contains filtered or unexported methods
}

func BuildOption

func BuildOption(
	parentID ids.ID,
	innerBytes []byte,
) (Block, error)

BuildOption the option block [parentID] is the ID of this option's wrapper parent block [innerBytes] is the byte representation of a child option block

func Parse

func Parse(bytes []byte, chainID ids.ID) (Block, error)

Parse a block and verify that the signature attached to the block is valid for the certificate provided in the block and that the block has a valid representation.

func ParseWithoutVerification added in v1.11.6

func ParseWithoutVerification(bytes []byte) (Block, error)

ParseWithoutVerification parses a block without verifying that the signature on the block is correct or has valid representation.

type Epoch

type Epoch struct {
	PChainHeight uint64 `serialize:"true" json:"pChainHeight"`
	Number       uint64 `serialize:"true" json:"number"`
	StartTime    int64  `serialize:"true" json:"startTime"`
}
type Header interface {
	ChainID() ids.ID
	ParentID() ids.ID
	BodyID() ids.ID
	Bytes() []byte
}

func BuildHeader

func BuildHeader(
	chainID ids.ID,
	parentID ids.ID,
	bodyID ids.ID,
) (Header, error)

func ParseHeader

func ParseHeader(bytes []byte) (Header, error)

type ParseResult added in v1.11.11

type ParseResult struct {
	Block Block
	Err   error
}

func ParseBlocks added in v1.11.11

func ParseBlocks(blks [][]byte, chainID ids.ID) []ParseResult

ParseBlocks parses the given raw blocks into tuples of (Block, error). Each ParseResult is returned in the same order as its corresponding bytes in the input.

type SignedBlock

type SignedBlock interface {
	Block

	PChainHeight() uint64
	PChainEpoch() Epoch
	Timestamp() time.Time

	// Proposer returns the ID of the node that proposed this block. If no node
	// signed this block, [ids.EmptyNodeID] will be returned.
	Proposer() ids.NodeID
}

func Build

func Build(
	parentID ids.ID,
	timestamp time.Time,
	pChainHeight uint64,
	epoch Epoch,
	cert *staking.Certificate,
	blockBytes []byte,
	chainID ids.ID,
	key crypto.Signer,
) (SignedBlock, error)

func BuildUnsigned

func BuildUnsigned(
	parentID ids.ID,
	timestamp time.Time,
	pChainHeight uint64,
	epoch Epoch,
	blockBytes []byte,
) (SignedBlock, error)

Jump to

Keyboard shortcuts

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