Skip to content
This repository has been archived by the owner on Aug 19, 2022. It is now read-only.

Commit

Permalink
Update val to uint128
Browse files Browse the repository at this point in the history
  • Loading branch information
nanexcool committed Sep 19, 2018
1 parent efc685f commit ff8dcae
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/medianizer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ import "ds-value/value.sol";

contract Medianizer is DSThing {
event LogValue(bytes32 val);

uint128 val;
bool public has;

mapping (bytes12 => address) public values;
mapping (address => bytes12) public indexes;
bytes12 public next = 0x1;

uint96 public min = 0x1;

bytes32 val;
bool public has;

function set(address wat) public auth {
bytes12 nextId = bytes12(uint96(next) + 1);
require(nextId != 0x0);
Expand Down Expand Up @@ -74,17 +74,19 @@ contract Medianizer is DSThing {
}

function poke() external {
(val, has) = compute();
emit LogValue(val);
(bytes32 val_, bool has_) = compute();
val = uint128(val_);
has = has_;
emit LogValue(val_);
}

function peek() external view returns (bytes32, bool) {
return (val, has);
return (bytes32(val), has);
}

function read() external view returns (bytes32) {
require(has);
return val;
return bytes32(val);
}

function compute() public view returns (bytes32, bool) {
Expand Down Expand Up @@ -114,7 +116,7 @@ contract Medianizer is DSThing {
}

if (ctr < min) {
return (val, false);
return (bytes32(val), false);
}

bytes32 value;
Expand Down

0 comments on commit ff8dcae

Please sign in to comment.