I'm trying to store a dataset into a mapped struct. After adding more than 3 variables, seems type unspecific, the dataset is not stored anymore. I don't get any errors. Does this has to do something with memory? I'm using embark in a local testchain, so gas seems not to be the problem. Here the sample code:
pragma solidity ^0.4.2; contract test { struct Tree { int value1; int value2; int value3; int value4; } mapping(int => Tree) public dataItems; function addDataItem(int _value0,int _value1,int _value2,int _value3,int _value4) external { dataItems[_value0].value1= _value1; dataItems[_value0].value2= _value2; dataItems[_value0].value3= _value3; dataItems[_value0].value4= _value4; } function getvalue1(int _number) constant returns (int) { return dataItems[_number].value1; } }
When value4 is removed everything seems to work. Is there a right / other way to do this?
solc --version solc, the solidity compiler commandline interface Version: 0.4.4+commit.4633f3de.Darwin.appleclang Geth Version: 1.5.3-stable Git Commit: 978737f5d51ee4e60c00afb0c4ac8784b2faa059 Protocol Versions: [63 62] Network Id: 1 Go Version: go1.7.3 OS: darwin GOPATH= GOROOT=/usr/local/Cellar/go/1.7.3/libexec
Edit: This is a running out of gas problem as suggested by @BokkyPooBah. Adding additional gas in embark can be done like this:
test.addDataItem(1,1,1,1,1,{gas:150000})