Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions api-spec/openapi/swagger/ark/v1/admin.openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,14 @@
"type": "integer",
"format": "int64"
},
"roundMaxParticipantsCount": {
"type": "integer",
"format": "int64"
},
"roundMinParticipantsCount": {
"type": "integer",
"format": "int64"
},
"startTime": {
"type": "integer",
"format": "int64"
Expand Down
2 changes: 2 additions & 0 deletions api-spec/protobuf/ark/v1/admin.proto
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ message MarketHourConfig {
int64 end_time = 2;
int64 period = 3;
int64 round_interval = 4;
int64 round_min_participants_count = 5;
int64 round_max_participants_count = 6;
}

message IntentInput {
Expand Down
36 changes: 27 additions & 9 deletions api-spec/protobuf/gen/ark/v1/admin.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions api-spec/protobuf/gen/ark/v1/indexer.pb.rgw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions cmd/arkd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ var (
Usage: "Update the market hour configuration",
Flags: []cli.Flag{
marketHourStartDateFlag, marketHourEndDateFlag,
marketHourRoundIntervalFlag, marketHourPeriodFlag,
marketHourPeriodFlag, marketHourRoundIntervalFlag,
marketHourRoundMinParticipantsCountFlag, marketHourRoundMaxParticipantsCountFlag,
},
Action: updateMarketHourAction,
}
Expand Down Expand Up @@ -563,8 +564,10 @@ func updateMarketHourAction(ctx *cli.Context) error {
baseURL := ctx.String(urlFlagName)
startDate := ctx.String(marketHourStartDateFlagName)
endDate := ctx.String(marketHourEndDateFlagName)
roundInterval := ctx.Uint(marketHourRoundIntervalFlagName)
period := ctx.Uint(marketHourPeriodFlagName)
roundInterval := ctx.Uint(marketHourRoundIntervalFlagName)
roundMinParticipantsCount := ctx.Uint(marketHourRoundMinParticipantsCountFlagName)
roundMaxParticipantsCount := ctx.Uint(marketHourRoundMaxParticipantsCountFlagName)

if ctx.IsSet(marketHourStartDateFlagName) != ctx.IsSet(marketHourEndDateFlagName) {
return fmt.Errorf("--start-date and --end-date must be set together")
Expand Down Expand Up @@ -595,6 +598,12 @@ func updateMarketHourAction(ctx *cli.Context) error {
if period > 0 {
mhConfig["period"] = strconv.Itoa(int(period))
}
if roundMinParticipantsCount > 0 {
mhConfig["roundMinParticipantsCount"] = strconv.Itoa(int(roundMinParticipantsCount))
}
if roundMaxParticipantsCount > 0 {
mhConfig["roundMaxParticipantsCount"] = strconv.Itoa(int(roundMaxParticipantsCount))
}
Comment on lines +601 to +606
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Allow updating participant limits back to zero

Because we only include roundMinParticipantsCount/roundMaxParticipantsCount in the payload when their value is greater than zero, an operator cannot clear a previously configured limit (the API interprets the missing field as “leave the current value as-is”). Once a non-zero limit is set, there’s no way to revert to the default/unbounded 0. Please send the value whenever the flag is explicitly provided.

-	if roundMinParticipantsCount > 0 {
+	if ctx.IsSet(marketHourRoundMinParticipantsCountFlagName) {
 		mhConfig["roundMinParticipantsCount"] = strconv.Itoa(int(roundMinParticipantsCount))
 	}
-	if roundMaxParticipantsCount > 0 {
+	if ctx.IsSet(marketHourRoundMaxParticipantsCountFlagName) {
 		mhConfig["roundMaxParticipantsCount"] = strconv.Itoa(int(roundMaxParticipantsCount))
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if roundMinParticipantsCount > 0 {
mhConfig["roundMinParticipantsCount"] = strconv.Itoa(int(roundMinParticipantsCount))
}
if roundMaxParticipantsCount > 0 {
mhConfig["roundMaxParticipantsCount"] = strconv.Itoa(int(roundMaxParticipantsCount))
}
// allow explicit zero to clear previously set limits
if ctx.IsSet(marketHourRoundMinParticipantsCountFlagName) {
mhConfig["roundMinParticipantsCount"] = strconv.Itoa(int(roundMinParticipantsCount))
}
if ctx.IsSet(marketHourRoundMaxParticipantsCountFlagName) {
mhConfig["roundMaxParticipantsCount"] = strconv.Itoa(int(roundMaxParticipantsCount))
}
🤖 Prompt for AI Agents
In cmd/arkd/commands.go around lines 601 to 606, the code only adds
roundMinParticipantsCount/roundMaxParticipantsCount to mhConfig when the value
is >0, preventing an operator from clearing a previously set limit; change the
condition to check whether the corresponding CLI flag was explicitly provided
(e.g. Flags().Changed("roundMinParticipantsCount") /
Flags().Changed("roundMaxParticipantsCount")) and, if set, always write the
value (including zero) into mhConfig using strconv.Itoa so the payload can clear
the limit when the operator supplies 0.

bodyMap := map[string]map[string]string{"config": mhConfig}
body, err := json.Marshal(bodyMap)
if err != nil {
Expand Down
50 changes: 30 additions & 20 deletions cmd/arkd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,28 @@ import (
)

const (
urlFlagName = "url"
datadirFlagName = "datadir"
macaroonFlagName = "macaroon"
passwordFlagName = "password"
dbPathFlagName = "datadir"
mnemonicFlagName = "mnemonic"
gapLimitFlagName = "addr-gap-limit"
amountFlagName = "amount"
quantityFlagName = "quantity"
addressFlagName = "address"
intentIdsFlagName = "ids"
roundIdFlagName = "id"
beforeDateFlagName = "before-date"
afterDateFlagName = "after-date"
marketHourStartDateFlagName = "start-date"
marketHourEndDateFlagName = "end-date"
marketHourRoundIntervalFlagName = "round-interval"
marketHourPeriodFlagName = "period"
signerKeyFlagName = "signer-prvkey"
signerUrlFlagName = "signer-url"
urlFlagName = "url"
datadirFlagName = "datadir"
macaroonFlagName = "macaroon"
passwordFlagName = "password"
dbPathFlagName = "datadir"
mnemonicFlagName = "mnemonic"
gapLimitFlagName = "addr-gap-limit"
amountFlagName = "amount"
quantityFlagName = "quantity"
addressFlagName = "address"
intentIdsFlagName = "ids"
roundIdFlagName = "id"
beforeDateFlagName = "before-date"
afterDateFlagName = "after-date"
marketHourStartDateFlagName = "start-date"
marketHourEndDateFlagName = "end-date"
marketHourRoundIntervalFlagName = "round-interval"
marketHourPeriodFlagName = "period"
marketHourRoundMinParticipantsCountFlagName = "round-min-participants"
marketHourRoundMaxParticipantsCountFlagName = "round-max-participants"
signerKeyFlagName = "signer-prvkey"
signerUrlFlagName = "signer-url"

dateFormat = time.DateOnly
marketHourDateFormat = time.DateTime
Expand Down Expand Up @@ -135,6 +137,14 @@ var (
Name: marketHourPeriodFlagName,
Usage: "the market hour period in minutes, ie the interval between a market hour and the next one",
}
marketHourRoundMinParticipantsCountFlag = &cli.IntFlag{
Name: marketHourRoundMinParticipantsCountFlagName,
Usage: "the min number of participants per round during a market hour",
}
marketHourRoundMaxParticipantsCountFlag = &cli.IntFlag{
Name: marketHourRoundMaxParticipantsCountFlagName,
Usage: "the max number of participants per round during a market hour",
}
signerKeyFlag = &cli.StringFlag{
Name: signerKeyFlagName,
Usage: "the private key to be loaded to arkd wallet and used as signer",
Expand Down
Loading
Loading