Skip to content

Commit

Permalink
feat: optimize sync method
Browse files Browse the repository at this point in the history
  • Loading branch information
wei3erHase committed Aug 21, 2024
1 parent a2b599f commit 0eb3b45
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions solidity/contracts/DataReceiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ contract DataReceiver is IDataReceiver, Governable {
function syncObservations(bytes32 _poolSalt, uint256 _maxObservations) external {
IOracleSidechain _oracle = deployedOracles[_poolSalt];
if (address(_oracle) == address(0)) revert ZeroAddress();
IOracleSidechain.ObservationData[] memory _cachedObservationsData;
uint24 _currentNonce = _oracle.poolNonce();
IOracleSidechain.ObservationData[] memory _cachedObservationsData = _cachedObservations[_poolSalt][_currentNonce];
if (_cachedObservationsData.length == 0) revert ObservationsNotWritable();
uint256 _i;
while (_maxObservations == 0 || _i < _maxObservations) {
_cachedObservationsData = _cachedObservations[_poolSalt][_currentNonce];
Expand All @@ -103,6 +102,7 @@ contract DataReceiver is IDataReceiver, Governable {
break;
}
}
if (_i == 0) revert ObservationsNotWritable();
}

function whitelistAdapter(IBridgeReceiverAdapter _receiverAdapter, bool _isWhitelisted) external onlyGovernor {
Expand Down

0 comments on commit 0eb3b45

Please sign in to comment.