Simplify StakingEscrow.confirmActivity(): only direct calls from Worker

pull/1029/head
David Núñez 2019-06-08 12:11:52 +02:00
parent 1387683e35
commit dd23408ca7
1 changed files with 3 additions and 10 deletions

View File

@ -639,16 +639,9 @@ contract StakingEscrow is Issuer {
* @notice Confirm activity for the next period and mine for the previous period
**/
function confirmActivity() external {
address staker = msg.sender;
// sender is staker -> staker is an intermediary contract
if (stakerInfo[staker].value > 0) {
require(getWorkerByStaker(staker) == tx.origin, "Only worker can confirm activity");
} else {
// staker is not a contract -> sender is worker
staker = getStakerByWorker(msg.sender);
require(stakerInfo[staker].value > 0, "Staker must have a stake to confirm activity");
require(msg.sender == tx.origin, "Only worker with real address can confirm activity");
}
address staker = getStakerByWorker(msg.sender);
require(stakerInfo[staker].value > 0, "Staker must have a stake to confirm activity");
require(msg.sender == tx.origin, "Only worker with real address can confirm activity");
uint16 lastActivePeriod = getLastActivePeriod(staker);
mint(staker);