mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
- Solidity Upgraded up to v0.8.0 - Fixed and Added eth_chainId - Fix error in TransactionRecipet - Reward halving issue fixed
28 lines
992 B
Solidity
28 lines
992 B
Solidity
pragma solidity ^0.6.0;
|
|
interface DataFeed {
|
|
function getData(address token) external returns (uint value);
|
|
}
|
|
contract FeedConsumer {
|
|
DataFeed feed;
|
|
uint errorCount;
|
|
function rate(address token) public returns (uint value, bool success) {
|
|
// Permanently disable the mechanism if there are
|
|
// more than 10 errors.
|
|
require(errorCount < 10);
|
|
try feed.getData(token) returns (uint v) {
|
|
return (v, true);
|
|
} catch Error(string memory /*reason*/) {
|
|
// This is executed in case
|
|
// revert was called inside getData
|
|
// and a reason string was provided.
|
|
errorCount++;
|
|
return (0, false);
|
|
} catch (bytes memory /*lowLevelData*/) {
|
|
// This is executed in case revert() was used
|
|
// or there was a failing assertion, division
|
|
// by zero, etc. inside getData.
|
|
errorCount++;
|
|
return (0, false);
|
|
}
|
|
}
|
|
}
|