Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Nodes whitelist JSON-RPC APIs #476

Merged
merged 15 commits into from
Jan 9, 2019
Merged

Conversation

mark-terry
Copy link
Contributor

PR description

Added JSON-RPC methods to interact with the permissioning whitelist.

Fixed Issue(s)

#NC-1938

Copy link
Contributor

@lucassaldanha lucassaldanha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the trouble! :(

@lucassaldanha lucassaldanha changed the title Nc 1938 Nodes whitelist JSON-RPC APIs Dec 20, 2018
Copy link
Contributor

@lucassaldanha lucassaldanha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API is missing the perm_getNodesWhitelist method.

Copy link
Contributor

@lucassaldanha lucassaldanha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. The only thing that worries me is the exception handling on the Add and Remove nodes from the whitelist methods.

return new JsonRpcSuccessResponse(req.getId(), true);
} catch (IllegalArgumentException e) {
return new JsonRpcErrorResponse(req.getId(), JsonRpcError.NODE_WHITELIST_INVALID_ENTRY);
} catch (Exception e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think capturing a generic exception and assuming it was caused by a missing entry can be misleading. If it is a server failure or something else throwing the exception we will never know the true cause.

It would be good to either create specific exceptions (what we don't do much in Pantheon) or create an object that represents the status of the removeNodes operation. And based on the status you choose the correct error response. This is the approach I took for the Accounts whitelist.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. I'll implement a return object to make this a bit clearer and enable the generic handler to catch unexpected exceptions. 👍

return new JsonRpcSuccessResponse(req.getId(), true);
} catch (IllegalArgumentException e) {
return new JsonRpcErrorResponse(req.getId(), JsonRpcError.NODE_WHITELIST_INVALID_ENTRY);
} catch (Exception e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about the generic exception catch here.

Copy link
Contributor

@lucassaldanha lucassaldanha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After reviewing the acceptance tests with more details, I've noticed that we can change some things. I've added a comment on the specific place.

}
}

private String buildEnodeURI(final Peer s) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would this be better moved into Peer? e.g. peer.getEnodeURI()

@mark-terry mark-terry dismissed lucassaldanha’s stale review January 9, 2019 01:16

Concerns addressed in subsequent commit.

@mark-terry mark-terry merged commit 637af12 into PegaSysEng:master Jan 9, 2019
@mark-terry mark-terry deleted the NC-1938 branch January 9, 2019 01:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants