Skip to content

Conversation

bullet-tooth
Copy link
Contributor

@bullet-tooth bullet-tooth commented Feb 15, 2019

Overview


See: https://jira.bf.local/browse/ECR-2906

Definition of Done

  • There are no TODOs left in the code
  • Change is covered by automated tests
  • The coding guidelines are followed
  • Public API has Javadoc
  • Method preconditions are checked and documented in the Javadoc of the method
  • Changelog is updated if needed (in case of notable or breaking changes)
  • The continuous integration build passes

* @throws RuntimeException if the client is unable to complete a request
* (e.g., in case of connectivity problems)
*/
boolean healthCheck();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

more proper name?

Copy link
Contributor

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.
Copy link
Contributor Author

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? 🤔

Copy link
Contributor

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)

@coveralls
Copy link

coveralls commented Feb 15, 2019

Coverage Status

Coverage increased (+0.002%) to 85.53% when pulling 6562719 on ecr-2906 into b0c0d9c on master.

Copy link
Contributor

@dmitry-timofeev dmitry-timofeev left a 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.
Copy link
Contributor

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
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

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();
Copy link
Contributor

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.
Copy link
Contributor

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";
Copy link
Contributor

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();
Copy link
Contributor

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
Copy link
Contributor

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.

@bullet-tooth bullet-tooth added the work-in-progress 👷‍♂️ Do not expect reviewers to provide any feedback on WIP PRs — please ask for it explicitly! label Feb 19, 2019
added support for Exonum v10
class HealthCheckResponse {
boolean connectivity;
public enum ConsensusStatus {
ACTIVE,
Copy link
Contributor

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;
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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\"}",
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

created ECR-2925

@bullet-tooth bullet-tooth removed the work-in-progress 👷‍♂️ Do not expect reviewers to provide any feedback on WIP PRs — please ask for it explicitly! label Feb 19, 2019
package com.exonum.client.response;

/**
* Consensus status.
Copy link
Contributor

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;
Copy link
Contributor

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 {
Copy link
Contributor

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) {
Copy link
Contributor

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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

+createSubmitTxBody(String txMessage) 🔽 ?

@dmitry-timofeev
Copy link
Contributor

Awesome, let’s push it 💯

@dmitry-timofeev dmitry-timofeev merged commit 9e0a3dd into master Feb 19, 2019
@dmitry-timofeev dmitry-timofeev deleted the ecr-2906 branch February 19, 2019 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants