dedis / onet

Overlay Network for distributed protocols
GNU Lesser General Public License v3.0
51 stars 29 forks source link

use value instead of pointer where possible #594

Open tharvik opened 5 years ago

tharvik commented 5 years ago

There is many method defined with ptr receiver but which will fail when called with a nil. Also, many function takes a ptr to a value but doesn't handle the nil case. Even many struct contains list of non-nil pointers, ptr field which has to be defined, ...

For example, let's take Roster. NewRoster can return nil (instead of an error), but then, none of its methods will work. It contains a []*network.ServerIdentity, but all methods using it simply dereference each element. All its methods are ptr receiver but most (all maybe) doesn't mutate anything. Most methods return ptr but returning nil doesn't makes sense (or is used as an error channel).

cgrigis commented 5 years ago

A few pointers to feed the discussion: