Documentation ¶
Index ¶
- Constants
- func DBexists() bool
- func Handle(err error)
- func ToHex(num int64) []byte
- type Block
- type BlockChain
- func (blockchain *BlockChain) AddBlock(transactions []*Transaction) *Block
- func (blockchain *BlockChain) FindTransaction(ID []byte) (Transaction, error)
- func (blockchain *BlockChain) FindUTXO() map[string]TxOutputs
- func (blockchain *BlockChain) Iterator() *BlockChainIterator
- func (blockchain *BlockChain) SignTransaction(tx *Transaction, privKey ecdsa.PrivateKey)
- func (blockchain *BlockChain) VerifyTransaction(tx *Transaction) bool
- type BlockChainIterator
- type ProofOfWork
- type Transaction
- func (tx *Transaction) Hash() []byte
- func (tx *Transaction) IsCoinbase() bool
- func (tx Transaction) Serialize() []byte
- func (tx *Transaction) Sign(privateKey ecdsa.PrivateKey, prevTxs map[string]Transaction)
- func (tx Transaction) ToString() string
- func (tx *Transaction) TrimmedCopy() Transaction
- func (tx *Transaction) Verify(prevTxs map[string]Transaction) bool
- type TxInput
- type TxOutput
- type TxOutputs
- type UTXOSet
- func (u UTXOSet) CountTransactions() int
- func (u *UTXOSet) DeleteByPrefix(prefix []byte)
- func (u UTXOSet) FindSpendableOutputs(pubKeyHash []byte, amount int) (int, map[string][]int)
- func (u UTXOSet) FindUTXO(pubKeyHash []byte) []TxOutput
- func (u UTXOSet) Reindex()
- func (u *UTXOSet) Update(block *Block)
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
Create a block on the chain returns the 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 (blockchain *BlockChain) AddBlock(transactions []*Transaction) *Block
func (*BlockChain) FindTransaction ¶
func (blockchain *BlockChain) FindTransaction(ID []byte) (Transaction, error)
func (*BlockChain) FindUTXO ¶
func (blockchain *BlockChain) FindUTXO() map[string]TxOutputs
func (*BlockChain) Iterator ¶
func (blockchain *BlockChain) Iterator() *BlockChainIterator
func (*BlockChain) SignTransaction ¶
func (blockchain *BlockChain) SignTransaction(tx *Transaction, privKey ecdsa.PrivateKey)
func (*BlockChain) VerifyTransaction ¶
func (blockchain *BlockChain) VerifyTransaction(tx *Transaction) bool
type BlockChainIterator ¶
func (*BlockChainIterator) Next ¶
func (iter *BlockChainIterator) Next() *Block
type ProofOfWork ¶
func NewProof ¶
func NewProof(block *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, UTXO *UTXOSet) *Transaction
func (*Transaction) Hash ¶
func (tx *Transaction) Hash() []byte
func (*Transaction) IsCoinbase ¶
func (tx *Transaction) IsCoinbase() bool
func (Transaction) Serialize ¶
func (tx Transaction) Serialize() []byte
func (*Transaction) Sign ¶
func (tx *Transaction) Sign(privateKey ecdsa.PrivateKey, prevTxs map[string]Transaction)
func (Transaction) ToString ¶
func (tx Transaction) ToString() string
func (*Transaction) TrimmedCopy ¶
func (tx *Transaction) TrimmedCopy() Transaction
func (*Transaction) Verify ¶
func (tx *Transaction) Verify(prevTxs map[string]Transaction) bool
type UTXOSet ¶
type UTXOSet struct {
BlockChain *BlockChain
}
func (UTXOSet) CountTransactions ¶
func (*UTXOSet) DeleteByPrefix ¶
func (UTXOSet) FindSpendableOutputs ¶
Click to show internal directories.
Click to hide internal directories.