-
Notifications
You must be signed in to change notification settings - Fork 30
[ECR-2906] LC: Implemented System API endpoints support #716
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more proper name?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it required to write at each method that it works in a blocking way? 🤔
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.
I'd put that in a class level comment (unless we make a hybrid with both blocking and non-blocking APIs)
exonum-light-client/src/main/java/com/exonum/client/HealthCheckResponse.java
Outdated
Show resolved
Hide resolved
This reverts commit c5fd9f6
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
… 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we enforce any restrictions on the values?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it makes sense to request the core to use a consistent format? If so, please submit an issue.
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.
created ECR-2925
package com.exonum.client.response; | ||
|
||
/** | ||
* Consensus status. |
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.
of a particular node? of the whole network?
int size; | ||
public class HealthCheckInfo { | ||
ConsensusStatus consensusStatus; | ||
int connectionsNumber; |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+createSubmitTxBody(String txMessage)
🔽 ?
Awesome, let’s push it 💯 |
Overview
See: https://jira.bf.local/browse/ECR-2906
Definition of Done