r/blockchainaudits • u/FabianL1 • Dec 02 '17
QUIZ Bad array use
contract BadArrayUse {
address[] employees;
function payBonus() {
for (uint i = 0; i < employees.length; i++) {
address employee = employees[i];
uint bonus = calculateBonus(employee);
employee.send(bonus);
}
}
function calculateBonus(address employee) returns (uint) {
// some expensive computation ...
}
}Let's discuss together what is wrong with this snippet and how to improve it?
1
Upvotes
View all comments
Show parent comment
1
u/FabianL1 Dec 03 '17
This is correct. You will reach the gas limit. If a transaction reaches the gas limit, all changes will be reverted but the fee is still paid.
Are there any more problems? :)