block

package
v0.0.0-...-d596c11 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidTimestamp  = errors.New("block timestamp is too far in the future")
	ErrInvalidMerkleRoot = errors.New("invalid merkle root")
	ErrInvalidPrevHash   = errors.New("invalid previous block hash")
)

Functions

This section is empty.

Types

type Block

type Block struct {
	Header       *Header
	Transactions []*transaction.Transaction
}

func NewBlock

func NewBlock(header *Header, transactions []*transaction.Transaction) *Block

func (*Block) Hash

func (b *Block) Hash() []byte

func (*Block) Height

func (b *Block) Height() uint64
type Header struct {
	Version    uint32
	PrevHash   []byte
	MerkleRoot []byte
	Timestamp  int64
	Bits       uint32
	Nonce      uint64
}

Header represents the metadata of a block

func NewHeader

func NewHeader(prevHash, merkleRoot []byte, bits uint32) *Header

func (*Header) Hash

func (h *Header) Hash() []byte

type Validator

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

Validator handles block validation logic

func NewValidator

func NewValidator() *Validator

func (*Validator) ValidateBlock

func (v *Validator) ValidateBlock(block *Block, prevBlock *Block) error

Jump to

Keyboard shortcuts

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