This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//triggered when there's a consensus on the final result | |
event UpdatedRequest ( | |
uint id, | |
string urlToQuery, | |
string attributeToFetch, | |
string agreedValue | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//called by the oracle to record its answer | |
function updateRequest ( | |
uint _id, | |
string memory _valueRetrieved | |
) public { | |
Request storage currRequest = requests[_id]; | |
//check if oracle is in the list of trusted oracles | |
//and if the oracle hasn't voted yet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//event that triggers oracle outside of the blockchain | |
event NewRequest ( | |
uint id, | |
string urlToQuery, | |
string attributeToFetch | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createRequest ( | |
string memory _urlToQuery, | |
string memory _attributeToFetch | |
) | |
public | |
{ | |
uint lenght = requests.push(Request(currentId, _urlToQuery, _attributeToFetch, "")); | |
Request storage r = requests[lenght-1]; | |
// Hardcoded oracles address |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// defines a general api request | |
struct Request { | |
uint id; //request id | |
string urlToQuery; //API url | |
string attributeToFetch; //json attribute (key) to retrieve in the response | |
string agreedValue; //value from key | |
mapping(uint => string) anwers; //answers provided by the oracles | |
mapping(address => uint) quorum; //oracles which will query the answer (1=oracle hasn't voted, 2=oracle has voted) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity >=0.4.21 <0.6.0; | |
contract Oracle { | |
Request[] requests; //list of requests made to the contract | |
uint currentId = 0; //increasing request id | |
uint minQuorum = 2; //minimum number of responses to receive before declaring final result | |
uint totalOracleCount = 3; // Hardcoded oracle count | |
} |
I hereby claim:
- I am pedroduartecosta on github.
- I am pedroc (https://keybase.io/pedroc) on keybase.
- I have a public key ASAzPvCsscwUOE487ulXNKdyfk-Vfu-9gwYaWGmGJq1f-wo
To claim this, I am signing this object:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"lastUpload":"2019-04-22T16:12:57.533Z","extensionVersion":"v3.2.9"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val holdout = model.transform(test).select("prediction", "DelayOutputVar") | |
val rm = new RegressionMetrics(holdout.rdd.map(x => | |
(x(0).asInstanceOf[Double], x(1).asInstanceOf[Double]))) | |
println("sqrt(MSE): " + Math.sqrt(rm.meanSquaredError)) | |
println("mean absolute error: " + rm.meanAbsoluteError) | |
println("R Squared: " + rm.r2) | |
println("Explained Variance: " + rm.explainedVariance + "\n") |
NewerOlder