0

I am attempting to keep a log of when a user does certain things but when a new log event is reached the second log is overwritten instead of adding a new one to the array I am unsure as to why when push should not replace anything.

struct logger {
 bytes32[] who;
 uint64[]when;
}

mapping(address => logger) log;

function LogEvent( bytes32 _username, address _userAddress, uint64 _timestamp) public{
      log[_userAddress].who.push(_username);
      log[_userAddress].when.push(_timestamp);
}

function getlogs(address _userAddress) view public returns(bytes32[] memory, uint64[] memory){
    return(log[_userAddress].who, log[_userAddress].when);
}
0

Realized it was because I was using a call instead of a send, I am surprised to find calls making state changes though I thought that was outside of their capability

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.