Merge pull request #362 from filecoin-project/feat/chain-list-timestamp

add timestamp to chain list command output
This commit is contained in:
Whyrusleeping 2019-10-14 20:40:30 +09:00 committed by GitHub
commit b5ed3da230
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"time"
cid "github.com/ipfs/go-cid" cid "github.com/ipfs/go-cid"
"golang.org/x/xerrors" "golang.org/x/xerrors"
@ -321,7 +322,9 @@ var chainListCmd = &cli.Command{
} }
for i := len(tss) - 1; i >= 0; i-- { for i := len(tss) - 1; i >= 0; i-- {
fmt.Printf("%d [ ", tss[i].Height()) mints := tss[i].MinTimestamp()
t := time.Unix(int64(mints), 0)
fmt.Printf("%d: (%s) [ ", tss[i].Height(), t.Format(time.Stamp))
for _, b := range tss[i].Blocks() { for _, b := range tss[i].Blocks() {
fmt.Printf("%s: %s,", b.Cid(), b.Miner) fmt.Printf("%s: %s,", b.Cid(), b.Miner)
} }