Skip to content

Commit

Permalink
chore: modify comments about possible improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
gacevicljubisa committed Jul 1, 2024
1 parent 4587339 commit 31efa2d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/api/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,16 @@ func (s *Service) blocklistPeerHandler(w http.ResponseWriter, r *http.Request) {
return
}

// TODO: create custom validator for swarm.Address
// TODO: create custom validator for swarm.Address using go-playground/validator and use it here to validate the struct.
// Validator should be initialized in the service constructor of mocks as well.
if !payload.Address.IsValidNonEmpty() {
logger.Debug("peer address is not valid")
logger.Error(nil, "peer address is not valid")
jsonhttp.BadRequest(w, "peer address is not valid")
return
}

// TODO: possible to extend Blocklist method to return actual Duration value in jsonhttp response
if err := s.p2p.Blocklist(payload.Address, payload.Duration, payload.Reason); err != nil {
logger.Debug("blocklist peer failed", "peer_address", payload.Address, "error", err)
if errors.Is(err, p2p.ErrPeerNotFound) {
Expand Down

0 comments on commit 31efa2d

Please sign in to comment.