Documentation ¶
Index ¶
Constants ¶
View Source
const BLOCKTABLENAME = "blocks" //表名
View Source
const DBNAME = "blockchain.db" //数据库名
View Source
const TargetBit = 16
0000 0000 0000 0000 1001 0001 0000 .... 0001 256位Hash里面前面至少有16个零
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 Nonce int64 }
step1:创建Block结构体
type BlockChain ¶
step5:创建区块链
func CreateBlockChainWithGenesisBlock ¶
func CreateBlockChainWithGenesisBlock(data string) *BlockChain
step6:创建区块链,带有创世区块
func (*BlockChain) AddBlockToBlockChain ¶
func (bc *BlockChain) AddBlockToBlockChain(data string)
step7:添加一个新的区块,到区块链中
func (*BlockChain) PrintChains ¶
func (bc *BlockChain) PrintChains()
type BlockChainIterator ¶
type ProofOfWork ¶
step2:创建pow结构体
Click to show internal directories.
Click to hide internal directories.