Piston工具翻译-Steem网络的瑞士军刀(1)
本文翻译原文链接:http://cli.piston.rocks/en/develop/
它使用python3和piston-lib库,用于与steem网络交互。这里有piston-cli和piston-lib的链接。(这里就不给出链接方式了,大家可自行查阅原文)
命令行工具
用叫做piston
的命令行工具,可以让你查阅、发帖、回复、资金账号管理等操作。安装之后,你可以使用piston --help
命令查看有哪些可用功能。
安装
用pip安装
pip3 install piston-cli
手工安装
git clone https://github.com/xeroc/piston-cli
cd piston-cli
python3 setup.py install --user
更新
pip install --user --upgrade piston-cli
参与开发
如果你想为此项目贡献力量,请不要犹豫,直接拉分支提交代码或联系我。
API连接点
this.piston.rocks
我们使用this.piston.rocks
作为API的连接端点,但它只是一个试验性质的。你可以免费使用,用于原型验证,但不要指望它是可靠的,也不要用于性能测试。
运行你自己的节点
假设您知道如何编译官方的STEEM守护进程,您也可以运行类似的节点。(链接请查看原文)
steemd节点
下面是steemd的配置文件config.ini
:
rpc-endpoint = 127.0.0.1:5090
seed-node=52.38.66.234:2001
seed-node=52.37.169.52:2001
seed-node=52.26.78.244:2001
seed-node=192.99.4.226:2001
seed-node=46.252.27.1:1337
seed-node=81.89.101.133:2001
seed-node=52.4.250.181:39705
seed-node=85.214.65.220:2001
seed-node=104.199.157.70:2001
seed-node=104.236.82.250:2001
seed-node=104.168.154.160:40696
seed-node=162.213.199.171:34191
seed-node=seed.steemed.net:2001
seed-node=steem.clawmap.com:2001
seed-node=seed.steemwitness.com:2001
seed-node=steem-seed1.abit-more.com:2001
enable-plugin = account_by_key
enable-plugin = account_history
enable-plugin = follow
enable-plugin = market_history
enable-plugin = tags
public-api = database_api login_api
public-api = account_by_key_api
public-api = follow_api
public-api = market_history_api
public-api = tag_api
这将打开本地主机的端口5090,接下来,您可以直接向公众开放这个端口,或者通过一个Web服务器(例如nginx),添加SSL、负载均衡、流控等能力。
Nginx服务器
this.piston.rocks
使用了nginx服务,提供了SSL加密、流控、负载平衡等能力,配置如下所示:
upstream websockets { # load balancing two nodes
server 127.0.0.1:5090;
server 127.0.0.1:5091;
}
server {
listen 443 ssl;
server_name this.piston.rocks;
root /var/www/html/;
keepalive_timeout 65;
keepalive_requests 100000;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
ssl_certificate /etc/letsencrypt/live/this.piston.rocks/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/this.piston.rocks/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
ssl_stapling on;
ssl_stapling_verify on;
add_header Strict-Transport-Security max-age=15768000;
location ~ ^(/|/ws) {
limit_req zone=ws burst=5;
access_log off;
proxy_pass http://websockets;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_next_upstream error timeout invalid_header http_500;
proxy_connect_timeout 2;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location ~ /.well-known {
allow all;
}
}
如upstream
配置块所示,它提供了两个steemd节点,用于负载平衡和容错能力。比如一个节点升级代码时,而另一个可以接管整个流量,反之亦然。