- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.6k
          refactor: move API functions from RPCHelpers.h to ApiVersion.h
          #5889
        
          New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
| Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@           Coverage Diff           @@
##           develop   #5889   +/-   ##
=======================================
  Coverage     78.3%   78.3%           
=======================================
  Files          817     816    -1     
  Lines        68944   68953    +9     
  Branches      8304    8303    -1     
=======================================
+ Hits         53989   54000   +11     
+ Misses       14955   14953    -2     
 🚀 New features to boost your workflow:
 | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments
        
          
                include/xrpl/protocol/ApiVersion.h
              
                Outdated
          
        
      | if (apiVersion == apiVersionIfUnspecified) | ||
| { | ||
| /** | ||
| * API version numbers used in API version 1 | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not a doxy comment that will actually work (reach documentation). You probably better use a simple comment instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
        
          
                include/xrpl/protocol/ApiVersion.h
              
                Outdated
          
        
      | * 3) the version number is unspecified and | ||
| * APIVersionIfUnspecified is out of the supported range | ||
| * | ||
| * @param value a Json value that may or may not specifies | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter is currently called "jv" not "value"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
        
          
                include/xrpl/protocol/ApiVersion.h
              
                Outdated
          
        
      |  | ||
| Json::Value const maxVersion( | ||
| betaEnabled ? RPC::apiBetaVersion : RPC::apiMaximumSupportedVersion); | ||
| Json::Value requestedVersion(RPC::apiVersionIfUnspecified); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand this is just moving code around but consider cleaning this up (e.g. adding some whitespace where applicable)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored in a62c8e7
        
          
                include/xrpl/protocol/ApiVersion.h
              
                Outdated
          
        
      | { | ||
| requestedVersion = jv.get(jss::api_version, requestedVersion); | ||
| } | ||
| if (!(requestedVersion.isInt() || requestedVersion.isUInt()) || | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This is a horrible condition. Any improvement here would be nice 🔢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored in a62c8e7
        
          
                include/xrpl/protocol/ApiVersion.h
              
                Outdated
          
        
      | XRPL_ASSERT( | ||
| apiVersion != apiInvalidVersion, | ||
| "ripple::RPC::setVersion : input is valid"); | ||
| auto&& object = addObject(parent, jss::version); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This auto&& is a bit confusing. According to addObject signature this would call the overload which returns by value if Object is not a Value. Is it some sort of shared pointer inside? I don't understand why setting fields on object below would make sense as object is technically a temporary here.
Also, Object is a terrible name for a template parameter - I did not even notice it at first and assumed that it's the Object type from the Json library. This definitely needs renaming at the very least but also try implementing some tests that use this function with Object (template type) be actual Object from Json library and see if it even does anything useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think adding tests etc for Object is out of scope of this PR but I'll look into a separate cleanup effort. Based on some preliminary digging I think there's a good chance we can get rid of that whole Object class and only use Json::Value everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did switch out the && for & in 7617f1b though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
High Level Overview of Change
This PR moves two functions,
setVersionandgetAPIVersionNumber, fromRPCHelpers.htoApiVersion.h. There are no functionality or code changes.Context of Change
Split out of #5684 to hopefully start making that PR a bit easier to review.
Type of Change
API Impact
N/A
Test Plan
CI passes
Future Tasks
Add another PR that creates
RPCLedgerHelpersand splits out that part of #5684, leaving only the actual functionality changes in #5684