[ECR-2906] LC: Implemented System API endpoints support - #716
Conversation
| * @throws RuntimeException if the client is unable to complete a request | ||
| * (e.g., in case of connectivity problems) | ||
| */ | ||
| boolean healthCheck(); |
There was a problem hiding this comment.
more proper name?
There was a problem hiding this comment.
isNodeConnected? isNodeInNetwork?
BTW, is it OK to get an exception if the client is not connected? (probably, yes, as we need to communicate different problems differently; but the helthCheck is kind of an innocent name)
|
|
||
| /** | ||
| * Returns <b>true</b> if the node is connected to the other peers. | ||
| * And <b>false</b> otherwise. |
There was a problem hiding this comment.
is it required to write at each method that it works in a blocking way? 🤔
There was a problem hiding this comment.
I'd put that in a class level comment (unless we make a hybrid with both blocking and non-blocking APIs)
This reverts commit c5fd9f6
dmitry-timofeev
left a comment
There was a problem hiding this comment.
Good, some naming/documentation suggestions.
|
|
||
| /** | ||
| * Returns a number of unconfirmed transactions those are currently located in | ||
| * the memory pool and are waiting for acceptance to a block. |
There was a problem hiding this comment.
Nit: AFAIK, it is not a memory pool (they are persisted to avoid their loss in case a node goes down).
| HashCode submitTransaction(TransactionMessage tx); | ||
|
|
||
| /** | ||
| * Returns a number of unconfirmed transactions those are currently located in |
There was a problem hiding this comment.
that/which are currently …
|
|
||
| /** | ||
| * Returns <b>true</b> if the node is connected to the other peers. | ||
| * And <b>false</b> otherwise. |
There was a problem hiding this comment.
I'd put that in a class level comment (unless we make a hybrid with both blocking and non-blocking APIs)
| int getUnconfirmedTransactions(); | ||
|
|
||
| /** | ||
| * Returns <b>true</b> if the node is connected to the other peers. |
There was a problem hiding this comment.
I'd not use bold for that, but no formatting or monospace.
|
|
||
| /** | ||
| * Returns <b>true</b> if the node is connected to the other peers. | ||
| * And <b>false</b> otherwise. |
There was a problem hiding this comment.
I'd consider simplifying to:
to the other peers; false — otherwise.
| * @throws RuntimeException if the client is unable to complete a request | ||
| * (e.g., in case of connectivity problems) | ||
| */ | ||
| boolean healthCheck(); |
There was a problem hiding this comment.
isNodeConnected? isNodeInNetwork?
BTW, is it OK to get an exception if the client is not connected? (probably, yes, as we need to communicate different problems differently; but the helthCheck is kind of an innocent name)
| int getUnconfirmedTransactions(); | ||
|
|
||
| /** | ||
| * Returns <b>true</b> if the node is connected to the other peers. |
There was a problem hiding this comment.
Shall it be connected to all peers to be in the network? Or some peers? Or at least one peer?
| @Test | ||
| void getUserAgentInfo() throws InterruptedException { | ||
| // Mock response | ||
| String mockResponse = "exonum 0.6.0/rustc 1.26.0 (2789b067d 2018-03-06)\n\n/Mac OS10.13.3"; |
There was a problem hiding this comment.
I see — a String will do 🙃
| * @throws RuntimeException if the client is unable to complete a request | ||
| * (e.g., in case of connectivity problems) | ||
| */ | ||
| int getUnconfirmedTransactions(); |
There was a problem hiding this comment.
Will such a name work well when we add getTransaction/getTransactions, as it does not return transactions, but their number? getNumUnconfirmedTransactions — will be more accurate, but I am not quite happy with the name length :-)
| * Main interface for Exonum Light client. | ||
| * Provides a convenient way for interaction with Exonum framework APIs. | ||
| * All the methods of the interface work in a blocking way | ||
| * i.e. invoke underlying request immediately, and blocks until the response can be processed |
There was a problem hiding this comment.
… and block until … or there is an error/an error occurs.
added support for Exonum v10
| class HealthCheckResponse { | ||
| boolean connectivity; | ||
| public enum ConsensusStatus { | ||
| ACTIVE, |
There was a problem hiding this comment.
Do you happen to know the difference between these two? As it is public, I'd document it.
| int size; | ||
| public class HealthCheckInfo { | ||
| ConsensusStatus consensusStatus; | ||
| int connectionsNumber; |
There was a problem hiding this comment.
Shall we enforce any restrictions on the values?
There was a problem hiding this comment.
do you mean negative values? Also, we have some restriction for a number of network nodes. But I'm not sure that LC should know about theoretical maximum of that count
There was a problem hiding this comment.
Yeah, I though mostly of that, because there might not be more elaborate (e.g., if the consensus is enabled, might we have any connections — I have no idea). But I agree it is not required to put here checks of maximum values (and we can skip negatives too)
| return ImmutableList.of( | ||
| Arguments.of("{\"consensus_status\": \"Enabled\", \"connectivity\": \"NotConnected\"}", | ||
| new HealthCheckInfo(ConsensusStatus.ENABLED, 0)), | ||
| Arguments.of("{\"consensus_status\": \"Disabled\", \"connectivity\": \"NotConnected\"}", |
There was a problem hiding this comment.
Do you think it makes sense to request the core to use a consistent format? If so, please submit an issue.
| package com.exonum.client.response; | ||
|
|
||
| /** | ||
| * Consensus status. |
There was a problem hiding this comment.
of a particular node? of the whole network?
| int size; | ||
| public class HealthCheckInfo { | ||
| ConsensusStatus consensusStatus; | ||
| int connectionsNumber; |
There was a problem hiding this comment.
Yeah, I though mostly of that, because there might not be more elaborate (e.g., if the consensus is enabled, might we have any connections — I have no idea). But I agree it is not required to put here checks of maximum values (and we can skip negatives too)
| * Json object wrapper for submit transaction response. | ||
| */ | ||
| @Value | ||
| class SubmitTxResponse { |
There was a problem hiding this comment.
Shan't it be static as aboe? Or is it by default?
| return json().toJson(request); | ||
| } | ||
|
|
||
| static HashCode submitTxParser(String json) { |
There was a problem hiding this comment.
+parseSubmitTxResponse(String response) (so that it is a verb describing the action, otherwise it sounds as it returns some kind of a parser)?
| */ | ||
| final class ExplorerApiHelper { | ||
|
|
||
| static String submitTxBody(String message) { |
There was a problem hiding this comment.
+createSubmitTxBody(String txMessage) 🔽 ?
|
Awesome, let’s push it 💯 |
Overview
See: https://jira.bf.local/browse/ECR-2906
Definition of Done