I verified that this is a problem:
Defining the fields as a struct{} will maintain their order as defined in the code.
I made a tool to generate test data and the above approach breaks agains the output from ssb-feed
. On this feed it happens on message seq:5049. Before the static [Previous, Author, Sequence, Timestamp, Hash, Content, Signature]
works but then, seq and author somehow switched, resulting in different hashes and signatures..
This ordering issue also confirms a problem @keks suspected. We have to reproduce this ordering when gossiping feeds to other peers. For practical reasons we will just save the message as raw bytes for later, I guess. I find all this quite depressing from a design perspective but it should work out.
Coming up next: making the tests pass for the new pretty printer. Ordering won't be a problem for it but sadly the go tokenizer hides commas and colons from the user, so it needs to keep track of object/array nesting..