[Ethereum] Problem accessing array inside struct

arrayseventssoliditystruct

Dealing with the code below:

contract myContract {

    struct myStruct{
        bytes32 name;
        bool active;
        uint[] changes;
    }

    myStruct[2] myStr;
    uint[] steps;

    Event activatedEvent(uint time);

    function myContract{
        myStr[0] = packStruct('foo', true, steps);
        myStr[1] = packStruct('bar', false, steps);
    }

    function activate(){
        myStruct ms = myStr[0]; 
        ms.changes.push(now);
        activatedEvent(now);
    }
}

If I call the activate() function, the activatedEvent does not get triggered. Anybody knows where I'm wrong? Any help appreciated.

Best Answer

A common reason that a transaction won't run as expected is that it runs out of gas. You can find this out from web3.eth.getTransactionReceipt(transactionHash).

If you did run out of gas, then you can send more. For example, if you are using web3, you can set the amount of gas to 1 million with web3.eth.sendTransaction({ ... , gas: 1000000}).

Please note~ I take no credit for this answer: the real answer came from user:eth in a comment. I would just like to see this question marked as answered.