Documentation
¶
Overview ¶
proof of work algorithm
Index ¶
- Constants
- func DBexists() bool
- func Handle(err error)
- func ToHex(num int64) []byte
- type Block
- type BlockChain
- func (chain *BlockChain) AddBlock(transaction []*Transaction)
- func (chain *BlockChain) FindSpendableOutputs(address string, amount int) (int, map[string][]int)
- func (chain *BlockChain) FindUTXO(address string) []TxOutput
- func (chain *BlockChain) FindUnspentTransactions(address string) []Transaction
- func (chain *BlockChain) Iterator() *BlockChainIterator
- type BlockChainIterator
- type ProofOfWork
- type Transaction
- type TxInput
- type TxOutput
Constants ¶
View Source
const Difficulty = 12
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Block ¶
type Block struct { Hash []byte Transactions []*Transaction PreviousHash []byte Nonce int }
func CreateBlock ¶
func CreateBlock(txs []*Transaction, previousHash []byte) *Block
func Deserialize ¶
func Genesis ¶
func Genesis(coinbase *Transaction) *Block
func (*Block) HashTransactions ¶
type BlockChain ¶
func ContinueBlockChain ¶
func ContinueBlockChain(address string) *BlockChain
func InitBlockChain ¶
func InitBlockChain(address string) *BlockChain
func (*BlockChain) AddBlock ¶
func (chain *BlockChain) AddBlock(transaction []*Transaction)
func (*BlockChain) FindSpendableOutputs ¶
func (*BlockChain) FindUTXO ¶
func (chain *BlockChain) FindUTXO(address string) []TxOutput
func (*BlockChain) FindUnspentTransactions ¶
func (chain *BlockChain) FindUnspentTransactions(address string) []Transaction
func (*BlockChain) Iterator ¶
func (chain *BlockChain) Iterator() *BlockChainIterator
type BlockChainIterator ¶
func (*BlockChainIterator) Next ¶
func (iter *BlockChainIterator) Next() *Block
type ProofOfWork ¶
func NewProof ¶
func NewProof(b *Block) *ProofOfWork
func (*ProofOfWork) InitData ¶
func (pow *ProofOfWork) InitData(nonce int) []byte
func (*ProofOfWork) Run ¶
func (pow *ProofOfWork) Run() (int, []byte)
func (*ProofOfWork) Validate ¶
func (pow *ProofOfWork) Validate() bool
type Transaction ¶
func CoinbaseTx ¶
func CoinbaseTx(to, data string) *Transaction
func NewTransaction ¶
func NewTransaction(from, to string, amount int, chain *BlockChain) *Transaction
func (*Transaction) IsCoinbase ¶
func (tx *Transaction) IsCoinbase() bool
func (*Transaction) SetID ¶
func (tx *Transaction) SetID()
Click to show internal directories.
Click to hide internal directories.