摘要: 代码重构: block.go文件: package main import ( "crypto/sha256" ) //定义区块结构 type Block struct { //前区块哈希 PrevBlockHash [] byte //当前区块哈希 Hash [] byte //数据,目前使用字节 阅读全文
posted @ 2020-11-21 21:41 北漂的尘埃 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 部分程序代码(添加区块): //添加区块 func (bc *BlockChain) AddBlock(data string) { //创建一个区块 //bc.Block的最后一个区块的Hash值就是当前新区块的PrevBlockHash lastBlock := bc.Blocks[len(bc 阅读全文
posted @ 2020-11-21 21:39 北漂的尘埃 阅读(84) 评论(0) 推荐(0) 编辑
摘要: 部分程序代码(区块链的定义及遍历打印): 1 //创建区块链,使用Block数组模拟 2 type BlockChain struct { 3 Blocks []*Block 4 } 5 6 //实现创建区块链的方法 7 func NewBlockChain() *BlockChain { 8 // 阅读全文
posted @ 2020-11-21 21:38 北漂的尘埃 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 部分程序代码(生成并调用hash代码): 1 //创建区块,对Block的每一个字段填充数据 2 func NewBlock(data string, prevBlockHash []byte) *Block{ 3 block := Block{ 4 PrevBlockHash: prevBlock 阅读全文
posted @ 2020-11-21 21:37 北漂的尘埃 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 浮动体代码及注释: 显示效果: 阅读全文
posted @ 2020-11-21 20:23 北漂的尘埃 阅读(1091) 评论(0) 推荐(0) 编辑
摘要: 表格插入代码及注释: 显示效果: 更多命令可以看相关文档,通过在命令行终端输入 texdoc booktab 等命令打开文档。 阅读全文
posted @ 2020-11-21 19:55 北漂的尘埃 阅读(501) 评论(0) 推荐(0) 编辑