Skip to content

Commit 9ff6fcf

Browse files
committed
feat: using slice of strings for remote addrs in node
1 parent 96ab817 commit 9ff6fcf

File tree

12 files changed

+268
-240
lines changed

12 files changed

+268
-240
lines changed

proto/sentinel/node/v3/events.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ message EventCreate {
1212
string node_address = 1;
1313
string gigabyte_prices = 2;
1414
string hourly_prices = 3;
15-
string remote_url = 4 [(gogoproto.customname) = "RemoteURL"];
15+
repeated string remote_addrs = 4;
1616
}
1717

1818
message EventPay {
@@ -33,7 +33,7 @@ message EventUpdateDetails {
3333
string node_address = 1;
3434
string gigabyte_prices = 2;
3535
string hourly_prices = 3;
36-
string remote_url = 4 [(gogoproto.customname) = "RemoteURL"];
36+
repeated string remote_addrs = 4;
3737
}
3838

3939
message EventUpdateStatus {

proto/sentinel/node/v3/msg.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ message MsgRegisterNodeRequest {
1414
string from = 1;
1515
repeated sentinel.types.v1.Price gigabyte_prices = 2 [(gogoproto.nullable) = false];
1616
repeated sentinel.types.v1.Price hourly_prices = 3 [(gogoproto.nullable) = false];
17-
string remote_url = 4 [(gogoproto.customname) = "RemoteURL"];
17+
repeated string remote_addrs = 4;
1818
}
1919

2020
message MsgUpdateNodeDetailsRequest {
2121
string from = 1;
2222
repeated sentinel.types.v1.Price gigabyte_prices = 2 [(gogoproto.nullable) = false];
2323
repeated sentinel.types.v1.Price hourly_prices = 3 [(gogoproto.nullable) = false];
24-
string remote_url = 4 [(gogoproto.customname) = "RemoteURL"];
24+
repeated string remote_addrs = 4;
2525
}
2626

2727
message MsgUpdateNodeStatusRequest {

proto/sentinel/node/v3/node.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ message Node {
1414
string address = 1;
1515
repeated sentinel.types.v1.Price gigabyte_prices = 2 [(gogoproto.nullable) = false];
1616
repeated sentinel.types.v1.Price hourly_prices = 3 [(gogoproto.nullable) = false];
17-
string remote_url = 4 [(gogoproto.customname) = "RemoteURL"];
17+
repeated string remote_addrs = 4;
1818
google.protobuf.Timestamp inactive_at = 5 [
1919
(gogoproto.nullable) = false,
2020
(gogoproto.stdtime) = true

x/node/client/cli/flags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const (
1313
flagHourlyPrices = "hourly-prices"
1414
flagHours = "hours"
1515
flagMaxPrice = "max-price"
16-
flagRemoteURL = "remote-url"
16+
flagRemoteAddrs = "remote-addrs"
1717
)
1818

1919
func GetGigabytePrices(flags *pflag.FlagSet) (v1base.Prices, error) {

x/node/client/cli/tx.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package cli
22

33
import (
4+
"strings"
5+
46
"github.com/cosmos/cosmos-sdk/client"
57
"github.com/cosmos/cosmos-sdk/client/flags"
68
"github.com/cosmos/cosmos-sdk/client/tx"
@@ -13,8 +15,8 @@ import (
1315

1416
func txRegisterNode() *cobra.Command {
1517
cmd := &cobra.Command{
16-
Use: "register-node [remote-url]",
17-
Short: "Register a new node with a remote URL and pricing details",
18+
Use: "register-node [remote-addrs]",
19+
Short: "Register a new node with a remote addrs and pricing details",
1820
Args: cobra.ExactArgs(1),
1921
RunE: func(cmd *cobra.Command, args []string) error {
2022
ctx, err := client.GetClientTxContext(cmd)
@@ -36,7 +38,7 @@ func txRegisterNode() *cobra.Command {
3638
ctx.FromAddress.Bytes(),
3739
gigabytePrices,
3840
hourlyPrices,
39-
args[0],
41+
strings.Split(args[0], ","),
4042
)
4143
if err = msg.ValidateBasic(); err != nil {
4244
return err
@@ -73,7 +75,7 @@ func txUpdateNodeDetails() *cobra.Command {
7375
return err
7476
}
7577

76-
remoteURL, err := cmd.Flags().GetString(flagRemoteURL)
78+
remoteAddrs, err := cmd.Flags().GetString(flagRemoteAddrs)
7779
if err != nil {
7880
return err
7981
}
@@ -82,7 +84,7 @@ func txUpdateNodeDetails() *cobra.Command {
8284
ctx.FromAddress.Bytes(),
8385
gigabytePrices,
8486
hourlyPrices,
85-
remoteURL,
87+
strings.Split(remoteAddrs, ","),
8688
)
8789
if err = msg.ValidateBasic(); err != nil {
8890
return err
@@ -95,7 +97,7 @@ func txUpdateNodeDetails() *cobra.Command {
9597
flags.AddTxFlagsToCmd(cmd)
9698
cmd.Flags().String(flagGigabytePrices, "", "prices for one gigabyte of bandwidth (e.g., 1000token)")
9799
cmd.Flags().String(flagHourlyPrices, "", "prices for one hour of bandwidth (e.g., 500token)")
98-
cmd.Flags().String(flagRemoteURL, "", "remote URL address for the node")
100+
cmd.Flags().String(flagRemoteAddrs, "", "remote addrs for the node")
99101

100102
return cmd
101103
}

x/node/keeper/msg_handler.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (k *Keeper) HandleMsgRegisterNode(ctx sdk.Context, msg *v3.MsgRegisterNodeR
5151
Address: nodeAddr.String(),
5252
GigabytePrices: msg.GigabytePrices,
5353
HourlyPrices: msg.HourlyPrices,
54-
RemoteURL: msg.RemoteURL,
54+
RemoteAddrs: msg.RemoteAddrs,
5555
Status: v1base.StatusInactive,
5656
InactiveAt: time.Time{},
5757
StatusAt: ctx.BlockTime(),
@@ -67,7 +67,7 @@ func (k *Keeper) HandleMsgRegisterNode(ctx sdk.Context, msg *v3.MsgRegisterNodeR
6767
NodeAddress: node.Address,
6868
GigabytePrices: node.GetGigabytePrices().String(),
6969
HourlyPrices: node.GetHourlyPrices().String(),
70-
RemoteURL: node.RemoteURL,
70+
RemoteAddrs: node.RemoteAddrs,
7171
},
7272
)
7373

@@ -99,11 +99,11 @@ func (k *Keeper) HandleMsgUpdateNodeDetails(ctx sdk.Context, msg *v3.MsgUpdateNo
9999
return nil, types.NewErrorNodeNotFound(nodeAddr)
100100
}
101101

102-
// Apply updated prices and optional remote URL
102+
// Apply updated prices and optional remote addrs
103103
node.GigabytePrices = msg.GigabytePrices
104104
node.HourlyPrices = msg.HourlyPrices
105-
if msg.RemoteURL != "" {
106-
node.RemoteURL = msg.RemoteURL
105+
if len(msg.RemoteAddrs) > 0 {
106+
node.RemoteAddrs = msg.RemoteAddrs
107107
}
108108

109109
// Save the updated node to state
@@ -115,7 +115,7 @@ func (k *Keeper) HandleMsgUpdateNodeDetails(ctx sdk.Context, msg *v3.MsgUpdateNo
115115
NodeAddress: node.Address,
116116
GigabytePrices: node.GetGigabytePrices().String(),
117117
HourlyPrices: node.GetHourlyPrices().String(),
118-
RemoteURL: node.RemoteURL,
118+
RemoteAddrs: node.RemoteAddrs,
119119
},
120120
)
121121

x/node/migrations/migrator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (k *Migrator) migrateNodes(ctx sdk.Context) {
9090
Address: item.Address,
9191
GigabytePrices: gigabytePrices,
9292
HourlyPrices: hourlyPrices,
93-
RemoteURL: item.RemoteURL,
93+
RemoteAddrs: []string{item.RemoteURL},
9494
InactiveAt: item.InactiveAt,
9595
Status: item.Status,
9696
StatusAt: item.StatusAt,

x/node/types/v3/events.pb.go

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

0 commit comments

Comments
 (0)