bc

package module
v0.0.0-...-0147998 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const Difficulty = 12

Variables

This section is empty.

Functions

func ToHex

func ToHex(num int64) []byte

Types

type Block

type Block struct {
	Header
	Transactions []byte
}

func CreateBlock

func CreateBlock(data string, prevHash []byte) *Block

func Genesis

func Genesis() *Block

type BlockChain

type BlockChain struct {
	Blocks []*Block
}

func InitBlockChain

func InitBlockChain() *BlockChain

func (*BlockChain) AddBlock

func (chain *BlockChain) AddBlock(data string)
type Header struct {
	PrevHash         []byte
	Hash             []byte
	Timestamp        string
	Version          string
	Nonce            int
	DifficultyTarget int
}

type ProofOfWork

type ProofOfWork struct {
	Block  *Block
	Target *big.Int
}

func NewProofOfWork

func NewProofOfWork(b *Block) *ProofOfWork

func (*ProofOfWork) InitNonce

func (pow *ProofOfWork) InitNonce(nonce int) []byte

func (*ProofOfWork) Run

func (pow *ProofOfWork) Run() (int, []byte)

func (*ProofOfWork) Validate

func (pow *ProofOfWork) Validate() bool

Jump to

Keyboard shortcuts

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