Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBlockchainWithGenesisBlock ¶
func NewBlockchainWithGenesisBlock(address string)
Types ¶
type Block ¶
type Block struct { // 区块高度 Height int64 //上一个区块hash PreBlockHash []byte //交易数据 Txs []*Transaction //时间戳 TimeStamp int64 //本区块的hash Hash []byte // 随机值 Nonce int64 }
func DeSerialize ¶
func NewGenesisBlock ¶
func NewGenesisBlock(txs []*Transaction) *Block
type Blockchain ¶
var (
G_Blockchain *Blockchain
)
func (*Blockchain) AddBlock ¶
func (b *Blockchain) AddBlock(txs []*Transaction)
func (*Blockchain) Iterator ¶
func (blockchain *Blockchain) Iterator() *BlockchainIterator
func (*Blockchain) MineNewBlock ¶
func (blockchain *Blockchain) MineNewBlock(from []string, to []string, amount []string)
挖掘新的区块
func (*Blockchain) Printchain ¶
func (b *Blockchain) Printchain()
type BlockchainIterator ¶
func (*BlockchainIterator) Next ¶
func (blockchainIterator *BlockchainIterator) Next() *Block
type Transaction ¶
type Transaction struct { //1. 交易hash TxHash []byte //2. 输入 Vins []*TXInput //3. 输出 Vouts []*TXOutput }
func NewCoinbaseTransaction ¶
func NewCoinbaseTransaction(address string) *Transaction
func NewSimpleTransaction ¶
func NewSimpleTransaction(from string, to string, amount int) *Transaction
func UnSpentTransationsWithAdress ¶
func UnSpentTransationsWithAdress(address string) []*Transaction
如果一个地址对应的TXOutput未花费,那么这个Transaction就应该添加到数组中返回
func (*Transaction) HashTransaction ¶
func (tx *Transaction) HashTransaction()
Click to show internal directories.
Click to hide internal directories.