Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call reward for another eth addr #636

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions contracts/bonding/BondingManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,15 @@ contract BondingManager is ManagerProxyTarget, IBondingManager {
* @notice Mint token rewards for an active transcoder and its delegators
*/
function reward() external {
rewardWithHint(address(0), address(0));
rewardWithHint(msg.sender, address(0), address(0));
}

/**
* @notice Mint token rewards for an active transcoder and its delegators
* @param _transcoder Address of the transcoder to call reward as
*/
function rewardAs(address _transcoder) external {
rewardWithHint(_transcoder, address(0), address(0));
}

/**
Expand Down Expand Up @@ -857,24 +865,25 @@ contract BondingManager is ManagerProxyTarget, IBondingManager {
* @dev If the caller is in the transcoder pool, the caller can provide an optional hint for its insertion position in the
* pool via the `_newPosPrev` and `_newPosNext` params. A linear search will be executed starting at the hint to find the correct position.
* In the best case, the hint is the correct position so no search is executed. See SortedDoublyLL.sol for details on list hints
* @param _transcoder Address of the transcoder to call reward as
* @param _newPosPrev Address of previous transcoder in pool if the caller is in the pool
* @param _newPosNext Address of next transcoder in pool if the caller is in the pool
*/
function rewardWithHint(address _newPosPrev, address _newPosNext)
function rewardWithHint(address _transcoder, address _newPosPrev, address _newPosNext)
public
whenSystemNotPaused
currentRoundInitialized
autoCheckpoint(msg.sender)
autoCheckpoint(_transcoder)
{
uint256 currentRound = roundsManager().currentRound();

require(isActiveTranscoder(msg.sender), "caller must be an active transcoder");
require(isActiveTranscoder(_transcoder), "caller must be an active transcoder");
require(
transcoders[msg.sender].lastRewardRound != currentRound,
transcoders[_transcoder].lastRewardRound != currentRound,
"caller has already called reward for the current round"
);

Transcoder storage t = transcoders[msg.sender];
Transcoder storage t = transcoders[_transcoder];
EarningsPool.Data storage earningsPool = t.earningsPoolPerRound[currentRound];

// Set last round that transcoder called reward
Expand Down Expand Up @@ -907,17 +916,17 @@ contract BondingManager is ManagerProxyTarget, IBondingManager {

mtr.trustedTransferTokens(trsry, treasuryRewards);

emit TreasuryReward(msg.sender, trsry, treasuryRewards);
emit TreasuryReward(_transcoder, trsry, treasuryRewards);
}

uint256 transcoderRewards = totalRewardTokens.sub(treasuryRewards);

updateTranscoderWithRewards(msg.sender, transcoderRewards, currentRound, _newPosPrev, _newPosNext);
updateTranscoderWithRewards(_transcoder, transcoderRewards, currentRound, _newPosPrev, _newPosNext);

// Set last round that transcoder called reward
t.lastRewardRound = currentRound;

emit Reward(msg.sender, transcoderRewards);
emit Reward(_transcoder, transcoderRewards);
}

/**
Expand Down
1 change: 1 addition & 0 deletions test/gas-report/poolsize.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ describe("transcoder pool size gas report", () => {
await bondingManager
.connect(transcoders[0])
.rewardWithHint(
transcoders[0].address,
transcoders[1].address,
ethers.constants.AddressZero
)
Expand Down
1 change: 1 addition & 0 deletions test/integration/PoolUpdatesWithHints.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ describe("PoolUpdatesWithHints", () => {
await bondingManager
.connect(transcoders[size - 1])
.rewardWithHint(
transcoders[size - 1].address,
transcoders[size - 2].address,
ethers.constants.AddressZero
)
Expand Down
Loading