block

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2018 License: MIT Imports: 10 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
	Hash         []byte
	Transactions []transaction.Transaction
}

Block represents a simple block

func New

func New(previousBlockHash []byte, txs []transaction.Transaction) Block

New creates new block with given transactions. New block points to a previous block.

func NewGenesis

func NewGenesis(txs []transaction.Transaction) Block

NewGenesis creates genesis block with given transactions It's used for test only. You can get generated genesis block with blockchain.ReadGenesisBlock

func (Block) HexHash

func (b Block) HexHash() string

HexHash returns hex encoded block hash

type Header struct {
	PreviousBlockHash []byte
	MerkleRootHash    []byte
	Timestamp         int64
	Target            []byte
	Nonce             uint64
}

Header represents a block header

func (Header) Serialize

func (h Header) Serialize() []byte

Serialize serializes header. It used in the solver.

type Solver

type Solver interface {
	Solve(*Block) error
	Verify(Block) error
}

Solver represents a simple interface that knows how to hash a given block You can read more about different hashing algorithms here: https://en.bitcoin.it/wiki/Proof_of_work

func NewDSHA256Solver

func NewDSHA256Solver(td *big.Int) Solver

NewDSHA256Solver return a double sha256 solver implementation

Jump to

Keyboard shortcuts

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