Soaring Orchid Kangaroo
Medium
The unvouchUnhealthy
method is a convenience method that allows you to execute unvouch
and markUnhealthy
at once.
function unvouchUnhealthy(uint256 vouchId) external {
unvouch(vouchId);
markUnhealthy(vouchId);
}
For the unvouchUnhealthy
method to execute successfully, both the unvouch
and markUnhealthy
methods must succeed, but the value of activityCheckpoints.unvouchedAt
causes the markUnhealthy
method to always fail.
activityCheckpoints.unvouchedAt
uses_vouchShouldBePossibleUnhealthy
method to check if the vouch could become unhealthy, which checks if the currentblock.timestamp
is greater thanactivityCheckpoints.unvouchedAt + unhealthyResponsePeriod
.
function unvouch(uint256 vouchId) public {
uint256 profileId = IEthosProfile(
contractAddressManager.getContractAddressForName(ETHOS_PROFILE)
).verifiedProfileIdForAddress(msg.sender);
Vouch storage v = vouches[vouchId];
_vouchShouldExist(vouchId);
_vouchShouldBelongToAuthor(vouchId, profileId);
_vouchShouldBePossibleUnvouch(vouchId);
v.archived = true;
// solhint-disable-next-line not-rely-on-time
v.activityCheckpoints.unvouchedAt = block.timestamp;
- The
markUnhealthy
method requires that the currentblock.timestamp
is greater thanactivityCheckpoints.unvouchedAt + unhealthyResponsePeriod
to succeed.
function _vouchShouldBePossibleUnhealthy(uint256 vouchId) private view {
Vouch storage v = vouches[vouchId];
bool stillHasTime = block.timestamp <=
v.activityCheckpoints.unvouchedAt + unhealthyResponsePeriod;
- The default value of
unhealthyResponsePeriod
is set in theinitialize
method and is 24 hours.
function initialize(
address _owner,
address _admin,
address _expectedSigner,
address _signatureVerifier,
address _contractAddressManagerAddr,
address _weth
) external initializer {
__accessControl_init(
_owner,
_admin,
_expectedSigner,
_signatureVerifier,
_contractAddressManagerAddr
);
__UUPSUpgradeable_init();
configuredMinimumVouchAmount = ABSOLUTE_MINIMUM_VOUCH_AMOUNT;
unhealthyResponsePeriod = 24 hours;
In unvouch
method, we set activityCheckpoints.unvouchedAt
value to block.timestamp
, and in markUnhealthy
, we check if block.timestamp
is greater than activityCheckpoints.unvouchedAt + unhealthyResponsePeriod
, so unvouchUnhealthy
method always fails if unhealthyResponsePeriod
is not 0.
No response
No response
No response
No response
No response
No response