低层storj协议参考实现。
storjnode的Python项目详细描述
低层storj协议参考实现。
设置
Linux(ubuntu/mint/debian)
安装客户端
$ sudo pip install storjnode $ storjnode --help
更新客户端
$ sudo pip install storjnode --upgrade $ storjnode --help
OSX
安装客户端
$ brew install python $ rehash $ pip install storjnode $ storjnode --help
更新客户端
$ pip install storjnode --upgrade $ storjnode --help
python使用示例
正常使用
在python中启动和使用节点。
#!/usr/bin/env python# from examples/usage.pyimporttimeimportsignalimportstorjnodefromcrochetimportsetup,TimeoutError# start twisted via crochet and remove twisted handlersetup()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 DHTretrieved=node["examplekey"]# retrieve value by key from DHTprint("{key} => {value}".format(key="examplekey",value=retrieved))exceptTimeoutError:print("Got timeout error")exceptKeyboardInterrupt:passfinally:print("Stopping node")node.stop()
多节点使用
在python脚本中使用多个节点。
如果在一个脚本中使用多个节点,则必须指定它们 不同的港口。
请参见examples/network/multinode.py
节点消息
中继消息发送到路由表中离接收器最近的节点 接受中继消息的。一直持续到到达目的地 或者到达离接收器最近的节点。
因为消息总是只中继到当前可访问的节点 路由表,如果 它已连接到网络。
参见示例/network/relay_message.py
网络映射
您可以对网络进行爬网以创建网络地图。生成图形 也可以使用网络的 许多节点)。
请参见examples/network/map_network.py