I'm new to ethereum and getting my hands on contracts (in solidity). I think I have a very simple question but I can't for the life of me find the answer.
Simply put: How to I invoke an internal function with enough gas, if it's complex?
Example: Imagine I'm setting up a savings system for my children. They can deposit ether to the contract, and after 10 years their savings will be paid back - but to encourage them, there will be a bonus pool of ether in the contract. The kid who have deposited the most ether will also get the biggest chunk of the bonus pool. They may send from different wallets, so the contract keeps track of their names as well.
Example contract code:
contract Savings
{
struct Deposit
{
string name;
uint deposit;
}
uint cEnd = now + 10 years;
address[] dAddresses;
mapping(address => Deposit[]) deposits;
function depositEther(string _name)
{
deposits[msg.sender].push(Deposit({
name: _name,
deposit: msg.value
}));
dAddresses.push(msg.sender);
if(now >= cEnd){
distribute(); //CALL THIS WITH ENOUGH GAS
}
}
//complex calculations
function distribute() internal {
}
}
(I keep running into c.sendTransaction({from: to: gas: }) but I can not get that working.
If anyone could explain this to me in a simple way, I would be very happy.