-
Notifications
You must be signed in to change notification settings - Fork 14
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
Tentative of a cli template #54
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was a big chunk, we should have a call tomorrow to talk about it.
cmd/mod.go
Outdated
|
||
// Controller is the interface to implement to enable commands specific to | ||
// the ledger implementation. | ||
type Controller interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per se the name "controller" is correct, but for me it has more the meaning of the link beween a model and its representation in an MVC pattern. Maybe just CLI ?
cmd/mod.go
Outdated
Run(Context, Injector) error | ||
} | ||
|
||
// Request is a context to handle commands sent to the daemon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Request is a context": very confusing since there is exactly a "Context" struct bellow. So maybe update the comment or the Context
struct? Because there is a lot of different part in this package it is hard to see what would be THE Context. So maybe Context
should be RunContext
or something like that.
cmd/mod.go
Outdated
Out io.Writer | ||
} | ||
|
||
// Context is provide to an action to read the flags. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Context is provide to an action to read the flags. | |
// Context is provided to an action to read the flags. |
cmd/mod.go
Outdated
Execute(Request) error | ||
} | ||
|
||
// Builder defines how to build a list of commands to tweak the ledger. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"...to tweak the ledger" ?
EDIT: ok, didn't realize this abstraction was tight to a ledger configuration. I was under the impression that this abstraction would be totally independent and general-purpose.
cmd/app.go
Outdated
} | ||
|
||
// SocketDaemon is a daemon using UNIX socket. This allows the permissions to be | ||
// manage by the filesystem. A user must have read/write access to send a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// manage by the filesystem. A user must have read/write access to send a | |
// managed by the filesystem. A user must have read/write access to send a |
mino/minogrpc/server.go
Outdated
|
||
msg := &Certificate{Address: text, Value: cert} | ||
|
||
// Prepare the list of send back to the new node. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's too late for me to rephrase it, but it seems that a word should be changed.
mino/minogrpc/server.go
Outdated
|
||
func (o overlayServer) Share(ctx context.Context, msg *Certificate) (*CertificateAck, error) { | ||
// TODO: verify the validity of the certificate by connecting to the distant | ||
// node by that requires a protection against malicious share. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// node by that requires a protection against malicious share. | |
// node but that requires a protection against malicious share. |
mino/minogrpc/tokens/mod.go
Outdated
// Package tokens defines a token holder to generate and validate access tokens. | ||
// and provides an implementation in-memory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Package tokens defines a token holder to generate and validate access tokens. | |
// and provides an implementation in-memory. | |
// Package tokens defines a token holder to generate and validate access tokens | |
// and provides an in-memory implementation. |
} | ||
|
||
// Verify implements tokens.Holder. It returns true if the token is valid. | ||
func (holder *InMemoryHolder) Verify(token string) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't the token also store the node address it has been issued to? Right now someone could potentially eave drop on the network, stole the token and use it. Verify would then be
Verify(token string, origin mino.Address)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure where you can eavesdrop as the request is sent over TLS.
mino/minogrpc/server.go
Outdated
@@ -319,6 +461,7 @@ func makeCertificate() (*tls.Certificate, error) { | |||
|
|||
tmpl := &x509.Certificate{ | |||
SerialNumber: big.NewInt(1), | |||
DNSNames: []string{}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not used.. yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my mistake
@nkcr Thanks a lot, I wasn't super happy with the abstraction but it now looks much better. I changed one thing from our discussion this morning which is the Action for a node builder that is now a ActionTemplate that you transformed into an actual action which allows to have the abstraction at the top level. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice! I'm a fan of those package comments 😄
LGTM 🚀
Tentative of a cli template
This PR implements a tentative of a CLI template for the modules to follow to implement their own controllers that can be chosen before compiling an ledger application.
Also: implement a controller to create a network of nodes with grpc