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

Use JMESPath to retrieve a gas-price value from the Oracle JSON. #83

Open
DrPeterVanNostrand opened this issue May 22, 2018 · 0 comments
Assignees

Comments

@DrPeterVanNostrand
Copy link
Contributor

Currently, a static JSON schema is expected to be returned from the gas-price Oracle:

{
    "block_number": u64,
    "block_time": f64,
    "instant": f64,
    "standard": f64,
    "slow": f64,
    "fast": f64,
    "health": bool
}

We should allow users the ability to configure their bridge such that they can query a gas-price Oracle which returns a JSON schema differing from the above schema. This should be implemented using JMESPath expressions.

A new config option home/foreign.gas_price_oracle_expr should be added to account for the User's JMESPath expression.

Something similar to the following psuedo-code should be added to GasPriceStream's impl Stream.

let json_str = /* Use hyper to GET the Oracle's data, then string-ify the response body */
let resp_json = jmespath::Variable::from_json(json_str).map_err(|_| ... )?;
let gas_price = config.<home/foreign>.gas_price_expr
        .search(resp_json).unwrap_or(config.<home/foreign>.default_gas_price);
@DrPeterVanNostrand DrPeterVanNostrand self-assigned this May 22, 2018
noot pushed a commit to noot/poa-bridge that referenced this issue Jul 18, 2018
100% test coverage, issue 82, refactoring, documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant