block

package
v0.0.0-...-bc5e9de Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Header       Header
	Transactions []Transaction
}

Block is a struct that represents a block in the blockchain.

func NewBlock

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

func (*Block) Hash

func (b *Block) Hash() string

Hash returns the hash of the block.

type Header struct {
	Hash          string   `json:"hash"`
	PrevHash      string   `json:"prev_hash"`
	Timestamp     int64    `json:"timestamp"`
	Size          int      `json:"size"`
	Data          string   `json:"data"`
	Nonce         string   `json:"nonce"`
	MerkleRoot    string   `json:"merkle_root"`
	Height        *big.Int `json:"height"`
	Confirmations *big.Int `json:"confirmations"`
	Difficulty    *big.Int `json:"difficulty"`
	Bits          string   `json:"bits"`
	Reward        *big.Int `json:"reward"`
	FeeReward     *big.Int `json:"fee_reward"`
}

Header is a struct that represents a Header of block in the blockchain.

type Transaction

type Transaction struct {
	Input       account.Address `json:"input"`
	Output      account.Address `json:"output"`
	Description string          `json:"description"`
	Amount      float64         `json:"amount"`
	Fee         float64         `json:"fee"`
}

Transaction is a struct that represents a transaction in the blockchain.

func (*Transaction) Hash

func (t *Transaction) Hash() string

func (*Transaction) Validate

func (t *Transaction) Validate() bool

type Transactions

type Transactions []Transaction

func (*Transactions) MerkleRoot

func (t *Transactions) MerkleRoot() string

Jump to

Keyboard shortcuts

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