Skip to content
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

refactor: introduce generic 'Result' class and connect it to CreateTransaction and GetNewDestination #25218

Merged
merged 4 commits into from
Jul 12, 2022

Commits on Jul 8, 2022

  1. Introduce generic 'Result' class

    Useful to encapsulate the function result object (in case of having it) or, in case of failure, the failure reason.
    
    This let us clean lot of boilerplate code, as now instead of returning a boolean and having to add a ref arg for the
    return object and another ref for the error string. We can simply return a 'BResult<Obj>'.
    
    Example of what we currently have:
    ```
    bool doSomething(arg1, arg2, arg3, arg4, &result, &error_string) {
        do something...
        if (error) {
            error_string = "something bad happened";
            return false;
        }
    
        result = goodResult;
        return true;
    }
    ```
    
    Example of what we will get with this commit:
    ```
    BResult<Obj> doSomething(arg1, arg2, arg3, arg4) {
        do something...
        if (error) return {"something happened"};
    
        // good
        return {goodResult};
    }
    ```
    
    This allows a similar boilerplate cleanup on the function callers side as well. They don't have to add the extra
    pre-function-call error string and result object declarations to pass the references to the function.
    furszy committed Jul 8, 2022
    Configuration menu
    Copy the full SHA
    7a45c33 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    198fcca View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    2235172 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    111ea3a View commit details
    Browse the repository at this point in the history