mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
[NOD-475] Return error when requesting limit=0 (#505)
This commit is contained in:
parent
2402bae1ff
commit
1b6b02e0d2
@ -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()
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user