Modify print faulty sectors in provingFaultsCmd
This commit is contained in:
parent
55ed45f108
commit
24c7f47566
@ -3,7 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
|
||||||
"os"
|
"os"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
"time"
|
"time"
|
||||||
@ -73,14 +72,29 @@ var provingFaultsCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if len(faults) == 0 {
|
if len(faults) == 0 {
|
||||||
fmt.Println("no sector fault")
|
fmt.Println("no faulty sectors")
|
||||||
}
|
}
|
||||||
for _, num := range faults {
|
head, err := api.ChainHead(ctx)
|
||||||
num2 := num % (mas.Info.WindowPoStPartitionSectors * (miner.WPoStPeriodDeadlines - 1))
|
if err != nil {
|
||||||
deadline := uint64(math.Floor(float64(num2)/float64(mas.Info.WindowPoStPartitionSectors))) + 1
|
return xerrors.Errorf("getting chain head: %w", err)
|
||||||
fmt.Printf("sector number = %d,deadline = %d\n", num, deadline)
|
|
||||||
}
|
}
|
||||||
return nil
|
deadlines, err := api.StateMinerDeadlines(ctx, maddr, head.Key())
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("getting miner deadlines: %w", err)
|
||||||
|
}
|
||||||
|
tw := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0)
|
||||||
|
_, _ = fmt.Fprintln(tw, "deadline\tsectors")
|
||||||
|
for deadline, sectors := range deadlines.Due {
|
||||||
|
intersectSectors, _ := bitfield.IntersectBitField(sectors, mas.Faults)
|
||||||
|
if intersectSectors != nil {
|
||||||
|
allSectors, _ := intersectSectors.All(100000000000)
|
||||||
|
for _, num := range allSectors {
|
||||||
|
_, _ = fmt.Fprintf(tw, "%d\t%d\n", deadline, num)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return tw.Flush()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user