菜单开关

周梦康 发表于 2018-08-15 1006 次浏览

权益证明

type Block struct {
    Index     int
    Timestamp string
    BPM       int
    Hash      string
    PrevHash  string
    Validator string
}
func generateBlock(oldBlock Block, BPM int, address string) (Block, error) {

    var newBlock Block

    t := time.Now()

    newBlock.Index = oldBlock.Index + 1
    newBlock.Timestamp = t.String()
    newBlock.BPM = BPM
    newBlock.PrevHash = oldBlock.Hash
    newBlock.Hash = calculateBlockHash(newBlock)
    newBlock.Validator = address

    return newBlock, nil
}

增加权重

scanBalance := bufio.NewScanner(conn)
for scanBalance.Scan() {
    balance, err := strconv.Atoi(scanBalance.Text())
    if err != nil {
        log.Printf("%v not a number: %v", scanBalance.Text(), err)
        return
    }
    t := time.Now()
    address = calculateHash(t.String())
    validators[address] = balance
    fmt.Println(validators)
    break
}

评论列表