Merge pull request #8637 from filecoin-project/gstuart/cli-compact-partitions
Implement cli command for compactPartitions
This commit is contained in:
commit
c748b2bf9d
@ -58,6 +58,7 @@ var sectorsCmd = &cli.Command{
|
||||
sectorsCapacityCollateralCmd,
|
||||
sectorsBatching,
|
||||
sectorsRefreshPieceMatchingCmd,
|
||||
sectorsCompactPartitionsCmd,
|
||||
},
|
||||
}
|
||||
|
||||
@ -2088,3 +2089,89 @@ func yesno(b bool) string {
|
||||
}
|
||||
return color.RedString("NO")
|
||||
}
|
||||
|
||||
var sectorsCompactPartitionsCmd = &cli.Command{
|
||||
Name: "compact-partitions",
|
||||
Usage: "removes dead sectors from partitions and reduces the number of partitions used if possible",
|
||||
Flags: []cli.Flag{
|
||||
&cli.Uint64Flag{
|
||||
Name: "deadline",
|
||||
Usage: "the deadline to compact the partitions in",
|
||||
Required: true,
|
||||
},
|
||||
&cli.Int64SliceFlag{
|
||||
Name: "partitions",
|
||||
Usage: "list of partitions to compact sectors in",
|
||||
Required: true,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "really-do-it",
|
||||
Usage: "Actually send transaction performing the action",
|
||||
Value: false,
|
||||
},
|
||||
},
|
||||
Action: func(cctx *cli.Context) error {
|
||||
if !cctx.Bool("really-do-it") {
|
||||
fmt.Println("Pass --really-do-it to actually execute this action")
|
||||
return nil
|
||||
}
|
||||
|
||||
api, acloser, err := lcli.GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer acloser()
|
||||
|
||||
ctx := lcli.ReqContext(cctx)
|
||||
|
||||
maddr, err := getActorAddress(ctx, cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
minfo, err := api.StateMinerInfo(ctx, maddr, types.EmptyTSK)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
deadline := cctx.Uint64("deadline")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
parts := cctx.Int64Slice("partitions")
|
||||
if len(parts) <= 0 {
|
||||
return fmt.Errorf("must include at least one partition to compact")
|
||||
}
|
||||
|
||||
partitions := bitfield.BitField{}
|
||||
for _, partition := range parts {
|
||||
partitions.Set(uint64(partition))
|
||||
}
|
||||
|
||||
params := miner5.CompactPartitionsParams{
|
||||
Deadline: deadline,
|
||||
Partitions: partitions,
|
||||
}
|
||||
|
||||
sp, err := actors.SerializeParams(¶ms)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("serializing params: %w", err)
|
||||
}
|
||||
|
||||
smsg, err := api.MpoolPushMessage(ctx, &types.Message{
|
||||
From: minfo.Worker,
|
||||
To: maddr,
|
||||
Method: miner.Methods.CompactPartitions,
|
||||
Value: big.Zero(),
|
||||
Params: sp,
|
||||
}, nil)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("mpool push: %w", err)
|
||||
}
|
||||
|
||||
fmt.Println("Message CID:", smsg.Cid())
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
@ -1680,6 +1680,7 @@ COMMANDS:
|
||||
get-cc-collateral Get the collateral required to pledge a committed capacity sector
|
||||
batching manage batch sector operations
|
||||
match-pending-pieces force a refreshed match of pending pieces to open sectors without manually waiting for more deals
|
||||
compact-partitions removes dead sectors from partitions and reduces the number of partitions used if possible
|
||||
help, h Shows a list of commands or help for one command
|
||||
|
||||
OPTIONS:
|
||||
@ -2021,6 +2022,22 @@ OPTIONS:
|
||||
|
||||
```
|
||||
|
||||
### lotus-miner sectors compact-partitions
|
||||
```
|
||||
NAME:
|
||||
lotus-miner sectors compact-partitions - removes dead sectors from partitions and reduces the number of partitions used if possible
|
||||
|
||||
USAGE:
|
||||
lotus-miner sectors compact-partitions [command options] [arguments...]
|
||||
|
||||
OPTIONS:
|
||||
--deadline value the deadline to compact the partitions in (default: 0)
|
||||
--partitions value list of partitions to compact sectors in
|
||||
--really-do-it Actually send transaction performing the action (default: false)
|
||||
--help, -h show help (default: false)
|
||||
|
||||
```
|
||||
|
||||
## lotus-miner proving
|
||||
```
|
||||
NAME:
|
||||
|
Loading…
Reference in New Issue
Block a user