miner cli: Print allow/deny types in storage list

This commit is contained in:
Łukasz Magiera 2022-07-12 13:08:27 +02:00
parent 59d069dc4d
commit 43db2fb8a4
2 changed files with 22 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"math/bits"
"os"
"path/filepath"
"sort"
@ -345,6 +346,20 @@ var storageListCmd = &cli.Command{
fmt.Printf("\tAllowTo: %s\n", strings.Join(si.AllowTo, ", "))
}
if len(si.AllowTypes) > 0 || len(si.DenyTypes) > 0 {
denied := storiface.FTAll.SubAllowed(si.AllowTypes, si.DenyTypes)
allowed := storiface.FTAll ^ denied
switch {
case bits.OnesCount64(uint64(allowed)) == 0:
fmt.Printf("\tAllow Types: %s\n", color.RedString("None"))
case bits.OnesCount64(uint64(allowed)) < bits.OnesCount64(uint64(denied)):
fmt.Printf("\tAllow Types: %s\n", color.GreenString(strings.Join(allowed.Strings(), " ")))
default:
fmt.Printf("\tDeny Types: %s\n", color.RedString(strings.Join(denied.Strings(), " ")))
}
}
if localPath, ok := local[s.ID]; ok {
fmt.Printf("\tLocal: %s\n", color.GreenString(localPath))
}

View File

@ -24,6 +24,13 @@ const (
FTNone SectorFileType = 0
)
var FTAll = func() (out SectorFileType) {
for _, pathType := range PathTypes {
out |= pathType
}
return out
}()
const FSOverheadDen = 10
var FSOverheadSeal = map[SectorFileType]int{ // 10x overheads