在本机端口进行查询 由于是第一次运行该链 生成创世区块
通过http实现RPC命令的调用 实现添加块
查询当前所有块的信息
这里只做了两个命令 分别是get和write
源代码如下
基础功能的实现
package core
import (
"crypto/sha256"
"encoding/hex"
"time"
)
//定义区块
type Block struct {
Index int64 //区块编号
//生成新的区块
func GenerateNewBlock(preBlock *Block, data string) *Block {
newBlock := &Block{}
newBlock.Inde ...
阅读全文