Skip to content

Optimization for certain API Interfaces #5398

@lxcmyf

Description

@lxcmyf

Rationale

Currently, java-tron's HTTP interfaces support GET and POST requests. However, there are some inconsistencies in parameter validation and response between GET and POST calls for the same interface. Here are some examples:

case1: incorrect log level for invalid parameter

/wallet/getapprovedlist
When passing an invalid parameter like modifying type_url to type_url1, the server logs an ERROR:

18:02:57.889 ERROR [qtp464658113-329] [capsule](TransactionCapsule.java:350) Type of the Any message does not match the given class.

case2: inconsistent naming convention for parameters

/wallet/getavailableunfreezecount
image

The GET and POST requests have inconsistent naming for the parameter ownerAddress (GET) vs owner_address (POST).

case3: GET parameter handling contradicts business logic 

/wallet/getcanwithdrawunfreezeamount
image

For the timestamp parameter, the GET request throws NumberFormatException if missing while POST handles it as 0 by default, which aligns with business logic.

/wallet/getcandelegatedmaxsize
image

For the type parameter, GET request throws NumberFormatException if missing while POST handles it as 0 by default, which aligns with business logic.

/wallet/getblockbynum
image
For the num parameter, POST resolves it to 0 without passing it, and GET throws an error. To make it compatible, GET should be consistent with POST.

Implementation

To summarize, 3 cases are listed where GET and POST have inconsistencies. The solutions are as follows:

case1:change log level for invalid parameter validation

case2:standardize naming conventions

case3:align GET handling with POST logic

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions