Skip to content

Commit

Permalink
Merge pull request #13 from F483/master
Browse files Browse the repository at this point in the history
added client usage examples to README (issue #12)
  • Loading branch information
super3 committed Jun 27, 2015
2 parents 5b40af7 + 1076620 commit e2bb893
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 24 deletions.
80 changes: 58 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,69 +28,69 @@ python app.py
# API


### Registration
### Registration
Registration of farmers into the database. All farmers must register with the node before they
can perform any other actions.
can perform any other actions.

GET /api/register/<bitcoin address>/

Success Example:

GET /api/register/191GVvAaTRxLmz3rW3nU5jAV1rF186VxQc/
RESPONSE:
RESPONSE:
Status Code: 200
Text: User registered.

Fail Examples:

GET /api/register/notvalidaddress/
RESPONSE:
Status Code: 400
RESPONSE:
Status Code: 400
Text: Registration Failed: Invalid BTC Address.

GET /api/register/191GVvAaTRxLmz3rW3nU5jAV1rF186VxQc/
RESPONSE:
Status Code: 409
Text: Registration Failed: Address Already Is Registered.

### Ping-Pong
The farmer must maintain a rudimentary keep-alive with the node. This way we know if the farmer
has gone offline, and that we should not issue more challenges.

GET /api/register/<bitcoin address>/

Success Example:

GET /api/register/191GVvAaTRxLmz3rW3nU5jAV1rF186VxQc/
RESPONSE:
RESPONSE:
Status Code: 200
Text: Ping Accepted.

Fail Examples:

GET /api/ping/notvalidaddress/
RESPONSE:
Status Code: 400
RESPONSE:
Status Code: 400
Text: Ping Failed: Invalid BTC Address.

GET /api/ping/1EawBV7n7f2wDbgxJfNzo1eHyQ9Gj77oJd/
RESPONSE:
Status Code: 404
Text: Ping Failed: Farmer not found.

### Online Status
This API call was build to be human readable rather than machine readable. We get a simple
list of the all the farmers, their addresses, and when they did their last audit. We only
list of the all the farmers, their addresses, and when they did their last audit. We only
display farmers that have done a ping in the last `online_time` minutes, which by default
is 15 minutes.
is 15 minutes.

GET /api/online/

Success Examples:

GET /api/online/
RESPONSE:
Status Code: 200
RESPONSE:
Status Code: 200
Text:
1NeV1z5BMmFpCXgotwVeZjuN5k124W76MA | Last Seen: 14 second(s) | Last Audit: 22 hour(s)
137x69jwmcyy4mYCBtQUVoxa21p9Fxyss5 | Last Seen: 7 second(s) | Last Audit: 19 hour(s)
Expand All @@ -102,5 +102,41 @@ Success Examples:
# Client
1. Download and install [Python 3.4](https://www.python.org/downloads/release/python-343/)
2. Download the [client](https://github.com/Storj/dataserv/blob/master/tools/client.py)
3. Change `address = "YOUR ADDRESS HERE"` to whatever your Bitcoin address is
4. Run the script
3. Run the script

show programm help:

$ ./tools/client.py --help

show command help:

$ ./tools/client.py <COMMAND> --help

register address with default farmer:

$ ./tools/client.py register <YOUR_BITCOIN_ADDRESS>

register address with custom farmer:

$ ./tools/client.py register <YOUR_BITCOIN_ADDRESS> --url=<FARMER_URL>

ping address with default farmer:

$ ./tools/client.py ping <YOUR_BITCOIN_ADDRESS>

ping address with custom farmer:

$ ./tools/client.py ping <YOUR_BITCOIN_ADDRESS> --url=<FARMER_URL>

continuously ping address with default farmer in 15sec intervals:

$ ./tools/client.py poll <YOUR_BITCOIN_ADDRESS>

continuously ping address with custom farmer in 15sec intervals:

$ ./tools/client.py poll <YOUR_BITCOIN_ADDRESS> --url=<FARMER_URL>

continuously ping address with farmer using a given delay in seconds:

$ ./tools/client.py poll <YOUR_BITCOIN_ADDRESS> --delay=<SECONDS>

7 changes: 5 additions & 2 deletions tools/client.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env python3


import sys
import time
import urllib
Expand Down Expand Up @@ -162,9 +165,9 @@ def error(self, message):
help="Deley between each ping."
)
poll_parser.add_argument(
'--register', action='store_true',
'--register', action='store_true',
help="Register address before polling."
)
)

# get values
arguments = vars(parser.parse_args())
Expand Down

0 comments on commit e2bb893

Please sign in to comment.