Low level storj protocol reference implementation.
Project description
Low level storj protocol reference implementation.
Setup
Windows
Download latest windows release from github.
Extract the zip file to the folder where you wish to have it installed.
$ storjnode.exe version
Linux
Install client
$ sudo apt-get install python-pip python-dev graphviz $ sudo pip install storjnode $ storjnode version
Update client
$ sudo pip install storjnode --upgrade $ storjnode version
OSX
Install client
$ brew install python $ rehash $ pip install storjnode $ storjnode version
Update client
$ pip install storjnode --upgrade $ storjnode version
Python usage examples
Normal usage
Starting and using a node in python.
#!/usr/bin/env python
# from examples/usage.py
import time
import signal
import storjnode
from crochet import setup, TimeoutError
# start twisted via crochet and remove twisted handler
setup()
signal.signal(signal.SIGINT, signal.default_int_handler)
# start node (use bitcoin wif or hwif as node key)
node_key = "KzygUeD8qXaKBFdJWMk9c6AVib89keoZFBNdFBsj73kYZfAc4n1j"
node = storjnode.network.Node(node_key)
try:
print("Giving nodes some time to find peers.")
time.sleep(storjnode.network.WALK_TIMEOUT)
# The blocking node interface is very simple and behaves like a dict.
node["examplekey"] = "examplevalue" # put key value pair into DHT
retrieved = node["examplekey"] # retrieve value by key from DHT
print("{key} => {value}".format(key="examplekey", value=retrieved))
except TimeoutError:
print("Got timeout error")
except KeyboardInterrupt:
pass
finally:
print("Stopping node")
node.stop()
Multinode usage
Using more then one node in a python script.
If your are using more then one node in a single script, you must assign them different ports.
See examples/network/multinode.py
Node messaging
Nodes can send messages to each other. You can send direct messages or relay messages from node to node.
Direct messages:
The node spidercrawls the network to find the receiving node and sends the message directly. This will fail if the receiving node is behind a NAT and doesn’t have a public ip.
See examples/network/direct_message.py
Relay messages:
Relay messages are sent to the node nearest the receiver in the routing table that accepts the relay message. This continues until it reaches the destination or the nearest node to the receiver is reached.
Because messages are always relayed only to reachable nodes in the current routing table, there is a fare chance nodes behind a NAT can be reached if it is connected to the network.
See examples/network/relay_message.py
Network mapping
You can crawl the network to create a map of the network. Generating a graph of the network is also possable (though not reccomended for networks with many nodes).
See examples/network/map_network.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for storjnode-0.0.14-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9e6bec12ce07afef1f63fe4694eaa194f8718f7da2aabcc00ea8dc7c315b7e9 |
|
MD5 | 7ea339a36eab9f667fb3548a09530302 |
|
BLAKE2b-256 | a39e09337efe2728c65c0344899b70c9b0053bf2665859a7534cc3bb72435248 |