mirror of
https://github.com/fluencelabs/examples
synced 2025-06-11 00:51:21 +00:00
rm oracle reference
This commit is contained in:
@ -679,7 +679,7 @@ In this case, all response values are of the same magnitude, which is encouragin
|
|||||||
|
|
||||||
## Summary
|
## Summary
|
||||||
|
|
||||||
We developed a model to decentralize EVM hosting providers for our DApps and implemented a stylized solution with Fluence and Aqua. Specifically, we queried multiple centralized hosted EVM providers using the open Ethereum JSON-RPC API and settled on pulling the `latest` block as an indicator of reliability and "liveness" as opposed to, say, (stale) caches, unreachability or nefarious behavior.
|
We developed a model to decentralize blockchain APIs for our DApps and implemented a stylized solution with Fluence and Aqua. Specifically, we queried multiple centralized hosted EVM providers using the open Ethereum JSON-RPC API and settled on pulling the `latest` block as an indicator of reliability and "liveness" as opposed to, say, (stale) caches, unreachability or nefarious behavior.
|
||||||
|
|
||||||
Along our journey, we pretty much touched on every possible chokepoint and discussed what a feasible approach to a quorum might look like. However, we made a couple significant omissions:
|
Along our journey, we pretty much touched on every possible chokepoint and discussed what a feasible approach to a quorum might look like. However, we made a couple significant omissions:
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ fn mode<'a>(data: impl ExactSizeIterator<Item = &'a EVMResult>) -> (u32, u64) {
|
|||||||
.entry(
|
.entry(
|
||||||
match serde_json::from_str::<serde_json::Value>(&value.stdout) {
|
match serde_json::from_str::<serde_json::Value>(&value.stdout) {
|
||||||
Ok(r) => r["block-height"].as_u64().unwrap(),
|
Ok(r) => r["block-height"].as_u64().unwrap(),
|
||||||
Err(e) => 0 as u64,
|
Err(_e) => 0 as u64,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.or_insert(0) += 1;
|
.or_insert(0) += 1;
|
||||||
@ -65,7 +65,7 @@ pub struct EVMResult {
|
|||||||
|
|
||||||
#[marine]
|
#[marine]
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
pub struct Oracle {
|
pub struct Quorum {
|
||||||
pub n: u32,
|
pub n: u32,
|
||||||
pub mode: u64,
|
pub mode: u64,
|
||||||
pub freq: u32,
|
pub freq: u32,
|
||||||
@ -73,9 +73,9 @@ pub struct Oracle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[marine]
|
#[marine]
|
||||||
pub fn point_estimate(data: Vec<EVMResult>, min_points: u32) -> Oracle {
|
pub fn point_estimate(data: Vec<EVMResult>, min_points: u32) -> Quorum {
|
||||||
if data.len() < min_points as usize {
|
if data.len() < min_points as usize {
|
||||||
return Oracle {
|
return Quorum {
|
||||||
err_str: format!(
|
err_str: format!(
|
||||||
"Expected at least {} points but only got {}.",
|
"Expected at least {} points but only got {}.",
|
||||||
min_points,
|
min_points,
|
||||||
@ -86,7 +86,7 @@ pub fn point_estimate(data: Vec<EVMResult>, min_points: u32) -> Oracle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if data.len() < 1 {
|
if data.len() < 1 {
|
||||||
return Oracle {
|
return Quorum {
|
||||||
err_str: format!("Expected at least one timestamp."),
|
err_str: format!("Expected at least one timestamp."),
|
||||||
..<_>::default()
|
..<_>::default()
|
||||||
};
|
};
|
||||||
@ -94,7 +94,7 @@ pub fn point_estimate(data: Vec<EVMResult>, min_points: u32) -> Oracle {
|
|||||||
|
|
||||||
let (freq, mode) = mode(data.iter());
|
let (freq, mode) = mode(data.iter());
|
||||||
|
|
||||||
Oracle {
|
Quorum {
|
||||||
n: data.len() as u32,
|
n: data.len() as u32,
|
||||||
mode,
|
mode,
|
||||||
freq,
|
freq,
|
||||||
|
Reference in New Issue
Block a user