firepear / petrel

It's like SQLite, but for networking
MIT License
20 stars 1 forks source link

Request ID should be part of header #58

Closed firepear closed 8 years ago

firepear commented 8 years ago

There should be a request id (or sequence number) as part of the header. It should be generated by the client, rather than tracked as an incrementing counter by the server.

[ LENGTH (32bit) | SEQ (32bit) | HMAC (32 bit, optional) | PAYLOAD ]
firepear commented 8 years ago

This is done, except that SEQ comes before LENGTH (such that it does not affect length).

I've just now realized that HMAC, which is also fixed-length, can be moved to precede LENGTH as well.

SEQ (4B) | HMAC (32B, opt) | LENGTH (4B) | PAYLOAD
firepear commented 8 years ago

And now THAT is done.

But I want to clean up variable names and comments, so that everything has clear and consistent names. Currently there's too much swapping between "message", "request", "response", and variants when referring to the payload.

A request or response is something that exists from the POV of the client or server. From inside the code talking to a socket (petrel-net.go), it's a transmission. And transmissions have these parts:

firepear commented 8 years ago