Replace structhash with json encoding

v0-8
proposal

#1

Based on discussion https://github.com/mesg-foundation/core/issues/718#issuecomment-455535167

The structhash do not support omitempty flag. Moreover it dosen’t:

So we need to fix it.

Is there a reason why we using this package instead of simple json?

we can use simply sha1.Sum(josn.Marshal(service)). End of story.

In that case we have well tested stable package and we can easily extend service struct by adding omitempty tag to every new field.

We just need to replace tag hash with json and get rid of dependency.


Milestone v0.8
#2

Just as a warning using json for hashing will work but if we need to serialize the service in json then we have something really dependent to the hash.
For example we want the Hash attribute in the json but we don’t want it in the hash. There is also the DeployedAt but i’m not even sure this is used.
The Hash attribute is probably a design issue and shouldn’t be here in the first but this is the kind of problem we can have using json.Marshal for the hashing method


#3

Anthony is right, we do need to encode in JSON some field that should not be for hash generation.

What about forking and improving the package structhash?


#4

Related to https://github.com/mesg-foundation/core/issues/718