Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JSONToSlice ¶
bc.exe send -from "["\troytan\"]" -to "["\Alice\"]" -value "["\10\"]"
Types ¶
type Block ¶
type Block struct { TimeStamp int64 //区块的时间戳 代表区块时间 Hash []byte //当前区块哈希 PrevBlockHash []byte //前区块哈希 Height int64 //区块的高度 Txs []*Transaction //交易数据 Nonce int64 //在运行pow时生成的哈希变化值,也代表pow运行时动态修改的数据 }
区块的基本结构以及功能管理文件 实现一个最基本的区块结构
func (*Block) HashTransaction ¶
把指定区块中的所有的交易都序列化(类Merkle树的哈希计算方法)
type BlockChain ¶
区块链的基本结构
func CreateBlockChainWithGensisBlock ¶
func CreateBlockChainWithGensisBlock(address string) *BlockChain
初始化区块链
func (*BlockChain) Iterator ¶
func (blc *BlockChain) Iterator() *BlockChainIterator
next()函数 创建迭代器对象 实现迭代函数next 获取到每一个区块
type BlockChainIterator ¶
实现迭代器基本结构
type ProofOfWork ¶
type ProofOfWork struct { //需要共识验证的区块 Block *Block // contains filtered or unexported fields }
工作量证明的结构
func (*ProofOfWork) Run ¶
func (proofOfWork *ProofOfWork) Run() ([]byte, int)
执行pow 比较哈希 返回哈希值以及碰撞的次数
type Transaction ¶
type Transaction struct { //交易的哈希(表示) TxHash []byte //输入列表 Vins []*TxInput //输出列表 Vouts []*TxOutput }
定义一个基本的交易结构
func (*Transaction) HashTransaction ¶
func (tx *Transaction) HashTransaction()
Click to show internal directories.
Click to hide internal directories.