Documentation ¶
Index ¶
- func DeserializeBlock(d []byte) types.Block
- func DeserializeTransaction(data []byte) types.Transaction
- func NewBlock(transactions []types.Transaction, prevBlockHash []byte, height int) (types.Block, error)
- func NewCoinBaseTX(to string, fees float64) types.Transaction
- func NewGenesisBlock(coinBase types.Transaction) (types.Block, error)
- func NewUTXOTransaction(targetWallet *wallet.Wallet, to string, amount, fee float64, utxoSet *UTXOSet) types.Transaction
- type BlockChain
- func (bc *BlockChain) AddBlock(block types.Block)
- func (bc *BlockChain) CloseDB(Defer bool)
- func (bc *BlockChain) FindTransaction(ID []byte) (types.Transaction, error)
- func (bc *BlockChain) FindUTXO() map[string]tx_io.TXOutputs
- func (bc *BlockChain) GetBestHeight() int
- func (bc *BlockChain) GetBlock(blockHash []byte) (types.Block, error)
- func (bc *BlockChain) GetBlockHashes(height int) [][]byte
- func (bc *BlockChain) Iterator() BlockChainIterator
- func (bc *BlockChain) MineBlock(minerAddress string, transactions []types.Transaction) (types.Block, error)
- func (bc *BlockChain) SignTransaction(tx types.Transaction, privKey []byte) types.Transaction
- func (bc *BlockChain) VerifyTransaction(tx types.Transaction) bool
- type BlockChainIterator
- type UTXOSet
- type Worker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeserializeBlock ¶
func DeserializeTransaction ¶
func DeserializeTransaction(data []byte) types.Transaction
func NewCoinBaseTX ¶
func NewCoinBaseTX(to string, fees float64) types.Transaction
func NewGenesisBlock ¶
func NewGenesisBlock(coinBase types.Transaction) (types.Block, error)
func NewUTXOTransaction ¶
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) 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 (UTXOSet) FindSpendableOutputs ¶
Click to show internal directories.
Click to hide internal directories.