blockchain

package
v0.0.0-...-7d4a125 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const MaxNonce = math.MaxInt64
View Source
const TargetBits uint = 20

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Timestamp           int64
	PrevBlockHash, Hash []byte
	Transactions        []*transaction.Transaction
	Nonce               int
}

func DeserializeBlock

func DeserializeBlock(hex []byte) (*Block, error)

func NewBlock

func NewBlock(txs []*transaction.Transaction, prevBlockHash []byte) *Block

func NewGenesisBlock

func NewGenesisBlock(coinbase *transaction.Transaction) *Block

func (*Block) HashTransactions

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

func (*Block) Serialize

func (b *Block) Serialize() ([]byte, error)

type Blockchain

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

func CreateBlockchain

func CreateBlockchain(addr string) (bc *Blockchain, err error)

func LoadBlockchain

func LoadBlockchain() (bc *Blockchain, err error)

func (*Blockchain) Close

func (bc *Blockchain) Close()

func (*Blockchain) FindTransaction

func (bc *Blockchain) FindTransaction(ID *transaction.IDType) (tx *transaction.Transaction, err error)

func (*Blockchain) Iterator

func (bc *Blockchain) Iterator() *Iterator

func (*Blockchain) MineBlock

func (bc *Blockchain) MineBlock(txs []*transaction.Transaction) (err error)

func (*Blockchain) SignTransaction

func (bc *Blockchain) SignTransaction(tx *transaction.Transaction, prv *ecdsa.PrivateKey) (err error)

func (*Blockchain) UTXOs

func (bc *Blockchain) UTXOs(addr string, amt int) (utxos []*transaction.OutputWraper, tot int, err error)

func (*Blockchain) VerifyTransaction

func (bc *Blockchain) VerifyTransaction(tx *transaction.Transaction) (valid bool, err error)

type Iterator

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

func (*Iterator) Next

func (bci *Iterator) Next() (*Block, error)

type PoW

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

func NewPoW

func NewPoW(block *Block) *PoW

func (*PoW) Run

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

func (*PoW) Validate

func (pow *PoW) Validate() bool

Jump to

Keyboard shortcuts

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