Solidity struct value not updating

lsseckmanlsseckman Member Posts: 4
edited January 2016 in Solidity
Having trouble with the following struct, updater and accessor function.
Update function returns SUCCESS code, which shows that the struct has been updated at some point.
However, when I access the pending function it returns the original status info.
This is all in the same contract, broken up for readability.
(states have different string lengths, looking into using Chriseth's StringUtils in the future)

Any reason why this wouldn't be updating the "state" string in the Pending struct?
// pending account struct.
struct Pending {
    string to;
    string from;
    string state;
    uint amount;
// mapping pending transactions
mapping(uint => Pending) public pendings;

function update(uint ref, string state) constant returns(uint result) {
    // confirm params have been passed in correctly
    if ( ref == 0 || bytes(state).length == 0 ){
        return MISSING_PARAM;
    // change 'state' variable of referenced 
	//      Pending struct to status integer
    pendings[ref].state = state;
    // confirm state variable in the pending struct has been altered
    if (bytes(pendings[ref].state).length != bytes(state).length){
      return NOT_UPDATED;
    return SUCCESS;

  // returns pending transaction associated with reference integer.
function pending(uint ref) constant returns(uint amount, string to, string from, uint index, string state) {
    var reference = pendings[ref];
    amount =    reference.amount;
    state =     reference.state;
    to =;
    from =      reference.from;
    index =     ref;


Sign In or Register to comment.