ibc-go icon indicating copy to clipboard operation
ibc-go copied to clipboard

Be consistent with receiver type on method definitions

Open DimitrisJim opened this issue 10 months ago • 1 comments

Reference comment: https://github.com/cosmos/ibc-go/pull/6103#discussion_r1559121898

We should try and not mix and mash pointer-value receivers on methods and instead consistently use one or the other. For types that need mutations and already have a method that receives value as a pointer, rest of methods can be amended to change from a value receiver to a pointer.

For small types that don't have a pointer receiver currently and also aren't costly to pass around as args, we can stick with value receivers.


For Admin Use

  • [ ] Not duplicate issue
  • [ ] Appropriate labels applied
  • [ ] Appropriate contributors tagged/assigned

DimitrisJim avatar Apr 15 '24 19:04 DimitrisJim

My vote: make all functions on keepers a reference. For state modifications it's not technically required, since different struct instances will be making changes to the same underlying store, but whenever we want to associate other forms of state (member fields, references etc. ) things become a headache.

chatton avatar Jul 11 '24 14:07 chatton