core

package
v0.0.0-...-cf6e08f Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2018 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeserializeBlock

func DeserializeBlock(d []byte) types.Block

func DeserializeTransaction

func DeserializeTransaction(data []byte) types.Transaction

func NewBlock

func NewBlock(transactions []types.Transaction, prevBlockHash []byte, height int) (types.Block, error)

func NewCoinBaseTX

func NewCoinBaseTX(to string, fees float64) types.Transaction

func NewGenesisBlock

func NewGenesisBlock(coinBase types.Transaction) (types.Block, error)

func NewUTXOTransaction

func NewUTXOTransaction(targetWallet *wallet.Wallet, to string, amount, fee float64, utxoSet *UTXOSet) types.Transaction

Types

type BlockChain

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

func CreateBlockChain

func CreateBlockChain(address string, cfg config.Config) BlockChain

func NewBlockChain

func NewBlockChain(cfg config.Config) BlockChain

func (*BlockChain) AddBlock

func (bc *BlockChain) AddBlock(block types.Block)

AddBlock writes given block to the database if it does not exist.

func (*BlockChain) CloseDB

func (bc *BlockChain) CloseDB(Defer bool)

func (*BlockChain) FindTransaction

func (bc *BlockChain) FindTransaction(ID []byte) (types.Transaction, error)

func (*BlockChain) FindUTXO

func (bc *BlockChain) FindUTXO() map[string]tx_io.TXOutputs

func (*BlockChain) GetBestHeight

func (bc *BlockChain) GetBestHeight() int

GetBestHeight returns the height of the last block.

func (*BlockChain) GetBlock

func (bc *BlockChain) GetBlock(blockHash []byte) (types.Block, error)

GetBlock retrieves a block by given hash and deserialize it.

func (*BlockChain) GetBlockHashes

func (bc *BlockChain) GetBlockHashes(height int) [][]byte

func (*BlockChain) Iterator

func (bc *BlockChain) Iterator() BlockChainIterator

Iterator creates and returns a new blockchain iterator

func (*BlockChain) MineBlock

func (bc *BlockChain) MineBlock(minerAddress string, transactions []types.Transaction) (types.Block, error)

MineBlock generates new block.

func (*BlockChain) SignTransaction

func (bc *BlockChain) SignTransaction(tx types.Transaction, privKey []byte) types.Transaction

func (*BlockChain) VerifyTransaction

func (bc *BlockChain) VerifyTransaction(tx types.Transaction) bool

type BlockChainIterator

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

func (*BlockChainIterator) End

func (bci *BlockChainIterator) End() bool

func (*BlockChainIterator) Next

func (bci *BlockChainIterator) Next() types.Block

type UTXOSet

type UTXOSet struct {
	BlockChain BlockChain
}

func (UTXOSet) CountTransactions

func (u UTXOSet) CountTransactions() int

func (UTXOSet) FindSpendableOutputs

func (u UTXOSet) FindSpendableOutputs(pubkeyHash []byte, amount float64) (float64, map[string][]int)

func (UTXOSet) FindUTXO

func (u UTXOSet) FindUTXO(pubKeyHash []byte) []tx_io.TXOutput

func (UTXOSet) Reindex

func (u UTXOSet) Reindex()

func (UTXOSet) Update

func (u UTXOSet) Update(block types.Block)

type Worker

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

func NewProofOfWork

func NewProofOfWork(block types.Block) Worker

func (*Worker) Run

func (w *Worker) Run() (int, []byte, error)

func (*Worker) Validate

func (w *Worker) Validate() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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