From a911c83e67f1d5e5934584e92c435fb8d473fc32 Mon Sep 17 00:00:00 2001 From: Nate Maninger Date: Thu, 19 Sep 2024 07:49:01 -0700 Subject: [PATCH] rhp/v4: use request validate --- rhp/v4/server.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/rhp/v4/server.go b/rhp/v4/server.go index d2eb229..1f3d35e 100644 --- a/rhp/v4/server.go +++ b/rhp/v4/server.go @@ -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 {