Skip to content

Commit 7f1cb0d

Browse files
authored
feat(spcli): make settle-deal optionally take deal id ranges (#13146)
1 parent 1badd5f commit 7f1cb0d

File tree

3 files changed

+38
-8
lines changed

3 files changed

+38
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- fix(spcli): send SettleDealPayments msg to f05 for `lotus-miner actor settle-deal` ([filecoin-project/lotus#13142](https://github.com/filecoin-project/lotus/pull/13142))
1717
- feat: ExpectedRewardForPower builtin utility function and `lotus-shed miner expected-reward` CLI command ([filecoin-project/lotus#13138](https://github.com/filecoin-project/lotus/pull/13138))
1818
- feat(gateway): add CORS headers if --cors is provided ([filecoin-project/lotus#13145](https://github.com/filecoin-project/lotus/pull/13145))
19+
- feat(spcli): make settle-deal optionally take deal id ranges ([filecoin-project/lotus#13146](https://github.com/filecoin-project/lotus/pull/13146))
1920

2021
# Node v1.33.0 / 2025-05-08
2122
The Lotus v1.33.0 release introduces experimental v2 APIs with F3 awareness, featuring a new TipSet selection mechanism that significantly enhances how applications interact with the Filecoin blockchain. This release candidate also adds F3-aware Ethereum APIs via the /v2 endpoint. All of the /v2 APIs implement intelligent fallback mechanisms between F3 and Expected Consensus and are exposed through the Lotus Gateway.

cli/spcli/actor.go

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"fmt"
66
"strconv"
7+
"strings"
78

89
"github.com/docker/go-units"
910
cbor "github.com/ipfs/go-ipld-cbor"
@@ -39,7 +40,7 @@ import (
3940
func ActorDealSettlementCmd(getActor ActorAddressGetter) *cli.Command {
4041
return &cli.Command{
4142
Name: "settle-deal",
42-
Usage: "Settle deals manually, if dealIds are not provided all deals will be settled",
43+
Usage: "Settle deals manually, if dealIds are not provided all deals will be settled. Deal IDs can be specified as individual numbers or ranges (e.g., '123 124 125-200 220')",
4344
ArgsUsage: "[...dealIds]",
4445
Flags: []cli.Flag{
4546
&cli.IntFlag{
@@ -70,12 +71,40 @@ func ActorDealSettlementCmd(getActor ActorAddressGetter) *cli.Command {
7071
// if no deal ids are provided, get all the deals for the miner
7172
if dealsIdArgs := cctx.Args().Slice(); len(dealsIdArgs) != 0 {
7273
for _, d := range dealsIdArgs {
73-
dealId, err = strconv.ParseUint(d, 10, 64)
74-
if err != nil {
75-
return xerrors.Errorf("Error parsing deal id: %w", err)
74+
// Check if it's a range (e.g., "125-200")
75+
if strings.Contains(d, "-") {
76+
parts := strings.Split(d, "-")
77+
if len(parts) != 2 {
78+
return xerrors.Errorf("Invalid range format: %s (expected format: start-end)", d)
79+
}
80+
81+
start, err := strconv.ParseUint(strings.TrimSpace(parts[0]), 10, 64)
82+
if err != nil {
83+
return xerrors.Errorf("Error parsing start of range %s: %w", d, err)
84+
}
85+
86+
end, err := strconv.ParseUint(strings.TrimSpace(parts[1]), 10, 64)
87+
if err != nil {
88+
return xerrors.Errorf("Error parsing end of range %s: %w", d, err)
89+
}
90+
91+
if start > end {
92+
return xerrors.Errorf("Invalid range %s: start must be less than or equal to end", d)
93+
}
94+
95+
// Add all deal IDs in the range (inclusive)
96+
for id := start; id <= end; id++ {
97+
dealIDs = append(dealIDs, id)
98+
}
99+
} else {
100+
// Parse as a single deal ID
101+
dealId, err = strconv.ParseUint(d, 10, 64)
102+
if err != nil {
103+
return xerrors.Errorf("Error parsing deal id: %w", err)
104+
}
105+
106+
dealIDs = append(dealIDs, dealId)
76107
}
77-
78-
dealIDs = append(dealIDs, dealId)
79108
}
80109
} else {
81110
if dealIDs, err = GetMinerAllDeals(ctx, api, maddr, types.EmptyTSK); err != nil {

documentation/en/cli-lotus-miner.md

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)