thiemowmde added a comment.

I agree this would be cool, and I was thinking about this multiple times. I was not able to come up with something obvious. I mean, it's quite trivial to say "the hash of a StringValue is just the SHA1 of the string". But how would you document this for every slightly more complex data structure? Where would this documentation live, if not in the code?

I think consistency is key. For example we could say that the hash is always the SHA1 of the JSON representation of the data structure in question. We need to specify a few additional details, like spacing and indention of the JSON (because this influences the string representation and the calculated SHA1), and most importantly the order of attributes, as well as the presence or absence of optional attributes.

Oh dear. Even this approach is not that obvious, and not that easy to reproduce in an other language. What if we add a new attribute? This must change existing hashes, even if the value does not change. How to deal with that? How to ever update external hash calculation algorithms? What if one user tries to calculate a hash based on a JSON encoding that adds spaces in "key": "value", and an other one that doesn't?

What's your suggestion?


TASK DETAIL
https://phabricator.wikimedia.org/T167759

EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: thiemowmde
Cc: thiemowmde, daniel, Aklapper, Smalyshev, Lucas_Werkmeister_WMDE, GoranSMilovanovic, QZanden, EBjune, merbst, Avner, debt, Gehel, Jonas, FloNight, Xmlizer, Izno, jkroll, Wikidata-bugs, Jdouglas, aude, Tobias1984, Manybubbles, Mbch331
_______________________________________________
Wikidata-bugs mailing list
Wikidata-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs

Reply via email to