Pre geturi hook
Traditionally, an oracle request will be run on each DSP a consumer is staked to with each DSP returning the result of that request before the final array of oracle responses is returned to the smart contract. In order to access the response each DSP is returning before it is returned, a hook has been added which can be accessed with the following syntax. This hook can be used to throw an assertion preventing the DSP from using CPU to process a transaction under certain circumstances:
1
// define custom filter
2
#undef ORACLE_HOOK_FILTER
3
#define ORACLE_HOOK_FILTER(uri, data) filter_result(uri, data);
4
​
5
void filter_result(std::vector<char> uri, std::vector<char> data){
6
// if assertion thrown here, DSP will not respond nor use CPU to process the geturi action
7
// shouldAbort is included here to prevent the DSP from retrying the oracle request
8
eosio::check(data.size() > 3, "shouldAbort, result too small");
9
}
Copied!
Copy link