add duration tracking to sync status
This commit is contained in:
parent
034f0cc479
commit
c302051bc2
@ -2,6 +2,7 @@ package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
"github.com/ipfs/go-filestore"
|
||||
@ -263,6 +264,10 @@ type ActiveSync struct {
|
||||
|
||||
Stage SyncStateStage
|
||||
Height uint64
|
||||
|
||||
Start time.Time
|
||||
End time.Time
|
||||
Message string
|
||||
}
|
||||
|
||||
type SyncState struct {
|
||||
|
@ -144,7 +144,11 @@ func (syncer *Syncer) InformNewHead(from peer.ID, fts *store.FullTipSet) {
|
||||
bestPweight := syncer.store.GetHeaviestTipSet().Blocks()[0].ParentWeight
|
||||
targetWeight := fts.TipSet().Blocks()[0].ParentWeight
|
||||
if targetWeight.LessThan(bestPweight) {
|
||||
log.Warn("incoming tipset does not appear to be better than our best chain, ignoring for now")
|
||||
var miners []string
|
||||
for _, blk := range fts.TipSet().Blocks() {
|
||||
miners = append(miners, blk.Miner.String())
|
||||
}
|
||||
log.Warnf("incoming tipset from %s does not appear to be better than our best chain, ignoring for now", miners)
|
||||
return
|
||||
}
|
||||
|
||||
|
18
cli/sync.go
18
cli/sync.go
@ -26,14 +26,14 @@ var syncStatusCmd = &cli.Command{
|
||||
Name: "status",
|
||||
Usage: "check sync status",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
api, closer, err := GetFullNodeAPI(cctx)
|
||||
apic, closer, err := GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer closer()
|
||||
ctx := ReqContext(cctx)
|
||||
|
||||
state, err := api.SyncState(ctx)
|
||||
state, err := apic.SyncState(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -43,6 +43,7 @@ var syncStatusCmd = &cli.Command{
|
||||
fmt.Printf("worker %d:\n", i)
|
||||
var base, target []cid.Cid
|
||||
var heightDiff int64
|
||||
var theight uint64
|
||||
if ss.Base != nil {
|
||||
base = ss.Base.Cids()
|
||||
heightDiff = int64(ss.Base.Height())
|
||||
@ -50,14 +51,25 @@ var syncStatusCmd = &cli.Command{
|
||||
if ss.Target != nil {
|
||||
target = ss.Target.Cids()
|
||||
heightDiff = int64(ss.Target.Height()) - heightDiff
|
||||
theight = ss.Target.Height()
|
||||
} else {
|
||||
heightDiff = 0
|
||||
}
|
||||
fmt.Printf("\tBase:\t%s\n", base)
|
||||
fmt.Printf("\tTarget:\t%s\n", target)
|
||||
fmt.Printf("\tTarget:\t%s (%d)\n", target, theight)
|
||||
fmt.Printf("\tHeight diff:\t%d\n", heightDiff)
|
||||
fmt.Printf("\tStage: %s\n", chain.SyncStageString(ss.Stage))
|
||||
fmt.Printf("\tHeight: %d\n", ss.Height)
|
||||
if ss.End.IsZero() {
|
||||
if !ss.Start.IsZero() {
|
||||
fmt.Printf("\tElapsed: %s\n", time.Since(ss.Start))
|
||||
}
|
||||
} else {
|
||||
fmt.Printf("\tElapsed: %s\n", ss.End.Sub(ss.Start))
|
||||
}
|
||||
if ss.Stage == api.StageSyncErrored {
|
||||
fmt.Printf("\tError: %s\n", ss.Message)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
@ -30,6 +30,9 @@ func (a *SyncAPI) SyncState(ctx context.Context) (*api.SyncState, error) {
|
||||
Target: ss.Target,
|
||||
Stage: ss.Stage,
|
||||
Height: ss.Height,
|
||||
Start: ss.Start,
|
||||
End: ss.End,
|
||||
Message: ss.Message,
|
||||
})
|
||||
}
|
||||
return out, nil
|
||||
|
Loading…
Reference in New Issue
Block a user