Documentation ¶
Overview ¶
implement a simple p2p blockchain
Index ¶
- Variables
- func CaculateBlockHash(block Block) string
- func CaculateHash(s string) string
- func CreateNode(port int, target string, seed int64) (string, string, error)
- func GetNodes() []string
- func GetTokenAge(id string) int64
- func HandleStream(s network.Stream)
- func InitNodeResource()
- func InitTokenAgeMap()
- func InitVoteMap()
- func IsBlockValid(newBlock, oldBlock Block) bool
- func MakeBasicHost(listenPort int, secio bool, randseed int64) (host.Host, string, string, error)
- func NodeTokenAgeMap() map[string]int64
- func NodeVoteMap() map[string]int
- func PickWinnerWithDpos() (bp string, err error)
- func PickWinnerWithPos() (bp string, err error)
- func ReadData(id string) string
- func SetTokenAge(id string, TokenAge int64)
- func Vote(id string, ticket int)
- func WriteData(address string, data int) (bool, error)
- type Block
Constants ¶
This section is empty.
Variables ¶
View Source
var BlockChain []Block
BlockChain slice to storage Block
Functions ¶
func GetTokenAge ¶
func InitNodeResource ¶
func InitNodeResource()
func InitTokenAgeMap ¶
func InitTokenAgeMap()
func InitVoteMap ¶
func InitVoteMap()
func MakeBasicHost ¶
MakeBasicHost 构建P2P网络
func NodeTokenAgeMap ¶
func NodeVoteMap ¶
func PickWinnerWithDpos ¶
PickWinner 根据投票数量选择生成区块的节点
func PickWinnerWithPos ¶
PickWinnerPos 根据代币和持有时间选择生成区块的节点
func SetTokenAge ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.