Skip to content

Commit

Permalink
rhp/v4: use request validate
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Sep 19, 2024
1 parent cce2d6b commit a911c83
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions rhp/v4/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,8 @@ func (s *Server) handleRPCReadSector(stream net.Conn) error {
return errorBadRequest("price table invalid: %v", err)
} else if err := token.Validate(); err != nil {
return errorBadRequest("account token invalid: %v", err)
}

switch {
case req.Length%rhp4.LeafSize != 0:
return errorBadRequest("requested length must be a multiple of segment size %v", rhp4.LeafSize)
case req.Offset+req.Length > rhp4.SectorSize:
return errorBadRequest("requested offset %v and length %v exceed sector size %v", req.Offset, req.Length, rhp4.SectorSize)
} else if err := req.Validate(); err != nil {
return errorBadRequest("request invalid: %v", err)
}

if err := s.contractor.DebitAccount(req.Token.Account, prices.RPCReadSectorCost(req.Length)); err != nil {
Expand Down

0 comments on commit a911c83

Please sign in to comment.