Contract does not get mined

desktopdandesktopdan Member Posts: 15
So I am stumped by this. I am running a private testnet based on this
And I have managed to write, compile, deploy and interact with the greeter
So I know that my basic setup works.

Then I tried a simple "lottery" where you can add players with a guess and print the guess of a player and I can compile, deploy and interact with that:

contract makedraw {
mapping (address => uint) public guessofPlayer;
mapping (uint => address) public playerIndex;
uint playerCount;
/* this one adds a new player to the array */
function addPlayer(address player, uint guess) {
guessofPlayer[player] = guess;
playerIndex[playerCount] = player;
playerCount += 1;
}
/*this one prints the guess of a player */
function printGuess(address player) returns(uint guess) {
return guessofPlayer[player];
}
}
But then I add a function to "run the lottery draw" and although it compiles and can get sent to the testnet as a transaction (I can see it appear in the logs), the transaction NEVER gets mined. And I can't figure out why. I stripped the function right back to see if I could understand what is going on. The below does nothing except loop through an array and declare "bob" the winner if any of the "guesses" is a random_number (always 8).

function lottery_draw() returns(string winner) {
winner = "no winner";
uint random_number = 8;
for(uint i=0; i< playerCount; i++)
{
if (guessofPlayer[playerIndex[i]] == random_number) winner = "bob";
}
return winner;

}
So I don't get it... any ideas? I am a bit of a noob in this, so am at a loss.

Thanks!

PS: I also tried to make the return value a type "address", but the compiler did not like that. Any ideas why?

Sign In or Register to comment.