[NOD-475] Return error when requesting limit=0 (#505)

This commit is contained in:
Dan Aharoni 2019-12-01 17:25:27 +02:00 committed by Svarog
parent 2402bae1ff
commit 1b6b02e0d2
2 changed files with 4 additions and 4 deletions

View File

@ -54,9 +54,9 @@ func GetBlockByHashHandler(blockHash string) (interface{}, error) {
// GetBlocksHandler searches for all blocks
func GetBlocksHandler(order string, skip uint64, limit uint64) (interface{}, error) {
if limit > maxGetBlocksLimit {
if limit < 1 || limit > maxGetBlocksLimit {
return nil, httpserverutils.NewHandlerError(http.StatusBadRequest,
errors.Errorf("Limit higher than %d or lower than 0 was requested.", maxGetBlocksLimit))
errors.Errorf("Limit higher than %d or lower than 1 was requested.", maxGetTransactionsLimit))
}
blocks := []*dbmodels.Block{}
db, err := database.DB()

View File

@ -79,9 +79,9 @@ func GetTransactionByHashHandler(txHash string) (interface{}, error) {
// GetTransactionsByAddressHandler searches for all transactions
// where the given address is either an input or an output.
func GetTransactionsByAddressHandler(address string, skip uint64, limit uint64) (interface{}, error) {
if limit > maxGetTransactionsLimit {
if limit < 1 || limit > maxGetTransactionsLimit {
return nil, httpserverutils.NewHandlerError(http.StatusBadRequest,
errors.Errorf("Limit higher than %d or lower than 0 was requested.", maxGetTransactionsLimit))
errors.Errorf("Limit higher than %d or lower than 1 was requested.", maxGetTransactionsLimit))
}
db, err := database.DB()