Skip to content

Commit

Permalink
Merge pull request #10 from Alethio/2.4.19
Browse files Browse the repository at this point in the history
2.4.19
  • Loading branch information
baxy authored Feb 28, 2019
2 parents eb619a3 + 58dba16 commit 36c75f4
Show file tree
Hide file tree
Showing 7 changed files with 230 additions and 118 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Changelog
All notable changes to this project will be documented in this file.

## [2.4.19] - 2019-02-28
- Nethermind support for the latest blocks filter ([#9](https://github.com/Alethio/ethstats-cli/issues/9))
- Added details for the authentication error if trying to change the network/server ([#9](https://github.com/Alethio/ethstats-cli/issues/9))
- Updated Readme file with more details ([#9](https://github.com/Alethio/ethstats-cli/issues/9))
- Fixed syncing bug

## [2.4.18] - 2019-02-18
- Show correct dashboard url when app starts
- Improvements reconnecting with the Ethereum node
Expand Down
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Geth, Parity, Pantheon, basically any Ethereum node that has RPC enabled.
- [Running](#running)
- [Register node](#register-node)
- [Config file](#config-file)
- [Node recovery](#node-recovery)
- [CLI Options](#cli-options)
- [Daemon](#daemon)
- [Docker](#docker)
Expand Down Expand Up @@ -80,6 +81,10 @@ $ ethstats-cli
The app is configured by default to connect to the Ethereum node on your local host (http://localhost:8545).
To connect to a node running on a different host see `--client-url` under [CLI Options](#cli-options).

The server that is connecting to by default is the one deployed for the Ethereum `mainnet`. For sending stats for a different network see the `--net` flag under [CLI Options](#cli-options).
Changing the network requires a new registration of the node. This is required because based on the network you specify at registration time the stats will be sent to a different server. Each server has its own nodes/secretKeys.
A new registration is possible if the [config file](#config-file) is deleted.

IMPORTANT: To be able to extract all statistics from the Ethereum node we recommend running the app on the same host. The usage information about the node like cpu and memory load cannot be extracted if on a different host.

## Register node
Expand All @@ -93,7 +98,10 @@ $ ethstats-cli --register --account-email [email protected] --node-name your_node_n

For more details on these options please see [CLI Options](#cli-options).

If the node is already registered and you still specify the `--register` option, it will be avoided. A new registration is possible if the [config file](#config-file) is deleted.
If the node is already registered and you still specify the `--register` option, it will be avoided.
A new registration is possible if the [config file](#config-file) is deleted.

NOTE: Every registered node will and must have its own secret key.

## Config file
After the node was successfully registered, a config file is created in the following location:
Expand All @@ -108,6 +116,31 @@ It persists the node name, the secret key received on successfully registration
- `--client-ipc-path`
- `--network`

## Node recovery

IMPORTANT: This is available ONLY in interactive mode.

If you lost your secret key or config file or accidentally deleted it and want to use the same node name previously registered, there is possible to recover it.
To do that start `ethstats-cli` and on startup by not having a config file it will try to register by asking you:
```
? Do you wish to install as a new node or as an existing one ?
New node
> Existing node
```
Using arrow keys select "Existing node", then you need to enter your email account which was used to register your node.

```
? Please enter account email:
```
After typing that in, next an email will be sent to that account with a list of all nodes registered with that email account. Every node name in the list will have attached a recovery hash.
Select the recovery hash of the node you want to recover and type it in at the following step.

```
? Please enter node recovery hash:
```
This should end with a successful registration of an existing node name.
Keep in mind that the list of recovery hashes sent in the email expires in 30 minutes.

# CLI Options:

```sh
Expand Down
17 changes: 16 additions & 1 deletion lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,22 @@ export default class Server {
}, this.pingInterval);
}
} else {
this.log.error(`Authentication error: ${JSON.stringify(response.errors)}`, false, true);
let errorMessage = `Authentication error: ${JSON.stringify(response.errors)}.`;
let possibleFlagErrorType = '';

if (this.cli.flags.net) {
possibleFlagErrorType = 'network';
}

if (this.cli.flags.serverUrl) {
possibleFlagErrorType = 'server';
}

if (possibleFlagErrorType !== '') {
errorMessage += ` You are trying to switch the ${possibleFlagErrorType}! Make sure the node is registered for the that ${possibleFlagErrorType}!`;
}

this.log.error(errorMessage, false, true);
}

this.isTryingToLogin = false;
Expand Down
16 changes: 10 additions & 6 deletions lib/client/protocol/Abstract.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export default class Abstract {

this.url = this.config.client.url;

this.lastSyncStatus = null;
this.lastSyncStatus = {
currentBlock: null
};
this.lastBlock = null;
this.isConnected = false;

Expand Down Expand Up @@ -78,9 +80,6 @@ export default class Abstract {

if (sync === true) {
syncParams.syncOperation = 'start';
if (this.protocol === 'http') {
this.web3.reset(true);
}
} else if (sync) {
let startingBlock = (sync.startingBlock) ? sync.startingBlock : ((sync.status) ? sync.status.StartingBlock : 0);
let currentBlock = (sync.currentBlock) ? sync.currentBlock : ((sync.status) ? sync.status.CurrentBlock : 0);
Expand All @@ -96,12 +95,17 @@ export default class Abstract {
syncParams.highestBlock = highestBlock;
} else {
syncParams.syncOperation = 'finish';
if (this.protocol === 'http') {
}

if (this.protocol === 'http') {
if (syncParams.syncOperation === 'start' || syncParams.syncOperation === 'progress') {
this.web3.reset(true);
} else {
this.setLatestBlocksFilter();
}
}

if (this.lastSyncStatus && (this.lastSyncStatus.currentBlock !== syncParams.currentBlock)) {
if (this.lastSyncStatus.currentBlock !== syncParams.currentBlock) {
this.lastSyncStatus = syncParams;
this.server.send('sync', syncParams);
this.lastBlock = null;
Expand Down
1 change: 1 addition & 0 deletions lib/client/protocol/Http.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export default class Http extends Abstract {
try {
this.web3.eth.filter('latest').watch((error, hash) => {
if (!error) {
hash = hash.value === undefined ? hash : hash.value;
this.blocksQueue.push(hash);
}
});
Expand Down
Loading

0 comments on commit 36c75f4

Please sign in to comment.