Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Naming of channel.Backend and wallet.Backend #171

Open
matthiasgeihs opened this issue Sep 1, 2021 · 1 comment
Open

Naming of channel.Backend and wallet.Backend #171

matthiasgeihs opened this issue Sep 1, 2021 · 1 comment

Comments

@matthiasgeihs
Copy link
Contributor

Context: Package channel and wallet have an interface type Backend that provides a set of utility functions.

Problem: The name Backend suggests that the type provides all kinds of backend functionality while in fact it only provides a set of static utility functions. This is not evident and causes confusion when working with the code.

Suggestion: We could rename type Backend to Util or Static to clarify that it is a static utility object.

Caveat: This would affect all backend implementations. However, if we want to change it, it's better to do it sooner than later.

@ggwpez
Copy link
Contributor

ggwpez commented Sep 1, 2021

Instead of choosing a general name, we could also try to be more specific.
To give an idea about what we are talking about:

wallet.Backend interface {
	DecodeAddress(io.Reader) (Address, error)
	DecodeSig(io.Reader) (Sig, error)
	VerifySignature(msg []byte, sign Sig, a Address) (bool, error)
}

Since we thought about removing DecodeSig, we could then rename the wallet Backend.
We could also split it in two interfaces if that makes it clearer, the SetBackend function would then accept multiple arguments.

channel.Backend interface {
	CalcID(*Params) ID
	Sign(wallet.Account, *Params, *State) (wallet.Sig, error)
	Verify(addr wallet.Address, params *Params, state *State, sig wallet.Sig) (bool, error)
	DecodeAsset(io.Reader) (Asset, error)
}

Maybe something similar is possible for the channel backend.

@ggwpez ggwpez added this to the Beautification milestone Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants