Exemple #1
0
func tuiLatestBlocks() {
	var err error
	state, err = api.GetLatestBlocks()
	if err != nil {
		log.Fatal(err)
	}

	err = termbox.Init()
	if err != nil {
		log.Fatal(err)
	}
	defer termbox.Close()

	selected = 1
	screenWidth, screenHeight = termbox.Size()
	screenScroll = 0

	draw()
	tuiPoll()
	termbox.Close()
	cliBlock(state.Blocks[selected-1].Hash)
	os.Exit(0)
}
Exemple #2
0
func cliLatestBlocks() {
	var miner string

	latestBlocks, err := api.GetLatestBlocks()
	if err != nil {
		log.Fatal(err)
	}

	for _, b := range latestBlocks.Blocks[0:20] {
		blockDatetimeUnix, _ := strconv.Atoi(b.Time)
		if err != nil {
			log.Fatal(err)
		}
		blockDatetime := time.Unix(int64(blockDatetimeUnix), 0)
		blockDatetimeHuman := blockDatetime.Format(dateTimeFormat)
		if b.PoolInfo.PoolName != "" {
			miner = "[" + b.PoolInfo.PoolName + "]"
		} else {
			miner = ""
		}
		size := b.Size / 1024
		fmt.Printf("#%d (%s) %dtxs %dKb %s\n", b.Height, blockDatetimeHuman, b.Txlength, size, miner)
	}
}