Documentation ¶
Index ¶
- Constants
- Variables
- func CaculateBlockHash(block Block) string
- func CaculateHash(s string) string
- func HandleStream(s network.Stream)
- func IsBlockValid(newBlock, oldBlock Block) bool
- func MakeBasicHost(listenPort int, secio bool, randseed int64) (host.Host, error)
- func PickWinner() (bp string)
- func Run(ctx *cli.Context) error
- func SavePeer(name string)
- type Block
- type Validator
Constants ¶
View Source
const ( // DefaultVote 节点默认的票数 DefaultVote = 10 // FileName 节点信息保存配置文件 FileName = "config.ini" )
View Source
const BPCount = 5
BPCount 区块生产者的数量
Variables ¶
View Source
var BlockChain []Block
BlockChain slice to storage Block
View Source
var NewNode = cli.Command{ Name: "new", Usage: "add a new node to p2p network", Flags: []cli.Flag{ cli.IntFlag{ Name: "port", Value: 3000, Usage: "新创建的节点端口号", }, cli.StringFlag{ Name: "target", Value: "", Usage: "目标节点", }, cli.BoolFlag{ Name: "secio", Usage: "是否打开secio", }, cli.Int64Flag{ Name: "seed", Value: 0, Usage: "生产随机数", }, }, Action: func(context *cli.Context) error { if err := Run(context); err != nil { return err } return nil }, }
NewNode 创建新的节点加入到P2P网络
Functions ¶
func MakeBasicHost ¶
MakeBasicHost 构建P2P网络
Types ¶
Click to show internal directories.
Click to hide internal directories.