Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Int64ToBytes ¶
Types ¶
type Block ¶
type Block struct {
// 区块高度
Height int64
// 当前区块 HASH 值
Hash []byte
// 上一个区块的 HASH 值
PrevBlockHash []byte
// 交易数据
Data []byte
// 时间戳
Timestamp int64
}
func CreateGenesisBlock ¶
CreateGenesisBlock 单独写一个方法,生成创世区块
type BlockChain ¶
type BlockChain struct {
Blocks []*Block // 存储有序的区块
}
func CreateBlockchainWithGenesisBlock ¶
func CreateBlockchainWithGenesisBlock() *BlockChain
CreateBlockchainWithGenesisBlock 创建带有创世区块的区块链
func (*BlockChain) AddBlockToBlockchain ¶
func (blc *BlockChain) AddBlockToBlockchain(data string, height int64, preHash []byte)
AddBlockToBlockchain 增加区块到区块链里面
Click to show internal directories.
Click to hide internal directories.