I am making some modifications to cryptonote-utils for a cryptonote with a different block format than what it is built for. I've never done serialization before so I am just now learning about the concept. Let's take this as our example from cryptonote_basic.h:
BEGIN_SERIALIZE()
VARINT_FIELD_N("major_version", major_version);
VARINT_FIELD(timestamp);
FIELD_N("nonce", nonce);
FIELD(nonce);
END_SERIALIZE()
I understand that we are essentially converting all of our fields to hex (EDIT:binary not hex) and lining them up against each other to be efficient and create our block, but I don't understand how that order is defined? Is it defined by the order that I write them within the BEGIN_SERIALIZE() macro or is the order based off of their tags (or something else maybe I am missing)? I would imagine they get serialized in the order I serialize them within the macro, but then I wonder why some fields have tags and others do not? Is the tag name important?
I'm not the best with templates, so looking through serialization.h is quite tough for me. I am also not quite sure when to use BEGIN_SERIALIZE_OBJECT vs BEGIN_SERIALIZE. Thanks for helping with my noob questions!