Skip to content

Commit

Permalink
Merge pull request #239 from SiaFoundation/chris/remove-duration-writ…
Browse files Browse the repository at this point in the history
…e-sector-rpc

Remove duration parameter from RPCWriteSectorRequest
  • Loading branch information
n8maninger authored Dec 2, 2024
2 parents d3d9f55 + 7980b61 commit 0f56b68
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 8 deletions.
2 changes: 0 additions & 2 deletions rhp/v4/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,13 +510,11 @@ func (r *RPCReadSectorResponse) maxLen() int {
func (r RPCWriteSectorRequest) encodeTo(e *types.Encoder) {
r.Prices.EncodeTo(e)
r.Token.encodeTo(e)
e.WriteUint64(r.Duration)
e.WriteUint64(r.DataLength)
}
func (r *RPCWriteSectorRequest) decodeFrom(d *types.Decoder) {
r.Prices.DecodeFrom(d)
r.Token.decodeFrom(d)
r.Duration = d.ReadUint64()
r.DataLength = d.ReadUint64()
}
func (r *RPCWriteSectorRequest) maxLen() int {
Expand Down
1 change: 0 additions & 1 deletion rhp/v4/rhp.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,6 @@ type (
RPCWriteSectorRequest struct {
Prices HostPrices `json:"prices"`
Token AccountToken `json:"token"`
Duration uint64 `json:"duration"`
DataLength uint64 `json:"dataLength"` // extended to SectorSize by host
}

Expand Down
6 changes: 1 addition & 5 deletions rhp/v4/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,13 @@ func (req *RPCReadSectorRequest) Validate(pk types.PublicKey) error {
}

// Validate validates a write sector request.
func (req *RPCWriteSectorRequest) Validate(pk types.PublicKey, maxDuration uint64) error {
func (req *RPCWriteSectorRequest) Validate(pk types.PublicKey) error {
if err := req.Prices.Validate(pk); err != nil {
return fmt.Errorf("prices are invalid: %w", err)
} else if err := req.Token.Validate(); err != nil {
return fmt.Errorf("token is invalid: %w", err)
}
switch {
case req.Duration == 0:
return errors.New("duration must be greater than 0")
case req.Duration > maxDuration:
return fmt.Errorf("duration exceeds maximum: %d > %d", req.Duration, maxDuration)
case req.DataLength == 0:
return errors.New("sector must not be empty")
case req.DataLength%LeafSize != 0:
Expand Down

0 comments on commit 0f56b68

Please sign in to comment.