Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Block ¶
type Block struct { //高度Height:其实就是区块的编号,第一个区块叫创世区块,高度为0 Height int64 //上一个区块的哈希值ProvHash: PrevBlockHash []byte //交易数据 date 目前先设计为[]byte,后期是Transaction Data []byte //时间戳 TimeStamp int64 //哈希值hash 32字节 64个16进制数 Hash []byte }
step1:创建Block结构体
type BlockChain ¶
type BlockChain struct {
Blocks []*Block //存储有序的区块
}
step5:创建区块链
func CreateBlockChainWithGenesisBlock ¶
func CreateBlockChainWithGenesisBlock(data string) *BlockChain
step6:创建区块链,带有创世区块
func (*BlockChain) AddBlockToBlockChain ¶
func (bc *BlockChain) AddBlockToBlockChain(data string, height int64, prevHash []byte)
step7:添加一个新的区块,到区块链中
Click to show internal directories.
Click to hide internal directories.