I am designing / developing a smart contract in which we have 2 types of object : moving object and non moving object. Both types state is changed time to time. ex. in case of moving object its location can be changed, but in non moving object we do not have location change, but also ex. we have object's owner change. So, I defined a struct
as follows:
struct Object{
byte[] nonMoveState;
byte[] MoveState;
}
mapping(address => Object) state;
And I also defined an event as follows to keep history of changes to show it in the transaction hash:
event changeAction(address indexed objectAdd, byte actionType, byte actionValue);
Now, I need to record all changes, ex. in case of moving object, its place is changed from Paris to London. Then, if I do it as follows:
function setAction(address indexed objectAdd, byte actionType, byte actionValue) public returns (bool) {
state[objectAdd].MoveState[].push("actionValue");
emit changeAction(address indexed objectAdd, byte actionType, byte actionValue);
return true;
}
And invoking function :
setAction(0xE07b6e5a2026CC916A4E2Beb03767ae0ED6af773, "change place", "Paris");
setAction(0xE07b6e5a2026CC916A4E2Beb03767ae0ED6af773, "change place", "London");
Is there something wrong?
***Additional Information : In fact, in case of moving object, the new "action" is read/written by RFID/NFC and then new state is stored in the blockchain.