go-filecoin编译安装与命令解释
go-filecoin 源码已经在2019年2月15日3:00(+8:00)发布了,可以使用github上已经编译好的0.0.1版本,还可以自己编译。
自己编译
安装环境
- 系统:我这里使用的是ubuntu 18.03.1 64位版本
- go语言环境(Go >= v1.11.2)
- Rush环境(Rust >= v1.31.0 and cargo)
- pkg-config工具(pkg-config)
- 国际互联网接入服务(部分代码会从golang.org拉取,需要科学上网工具)
添加环境变量,文件/etc/profile
export http_proxy=<http://172.16.1.8:1080>
export https_proxy=<http://172.16.1.8:1080>export PATH=$PATH:/usr/local/go/bin:/root/go/bin
export GOROOT=/usr/local/go
export GOPATH=/root/go
安装
#!/bin/bash
wget https://dl.google.com/go/go1.11.5.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.11.5.linux-amd64.tar.gzcurl https://sh.rustup.rs -sSf | shapt install -y pkg-config cargo
apt install -y jq libclang-dev clangecho $GOPATH
mkdir -p ${GOPATH}/src/github.com/filecoin-project
git clone https://github.com/filecoin-project/go-filecoin.git ${GOPATH}/src/github.com/filecoin-project/go-filecoin
cd ${GOPATH}/src/github.com/filecoin-project/go-filecoin
FILECOIN_USE_PRECOMPILED_RUST_PROOFS=true go run ./build/*.go deps# First, build the binary
go run ./build/*.go build# Install go-filecoin to ${GOPATH}/bin (necessary for tests)
go run ./build/*.go install# Then, run the tests.
go run ./build/*.go test# Build and test can be combined!
go run ./build/*.go best
需要注意一下,这里与官方给出的文档稍微有些差异,已经做了更改。
编译好之后,就可以运行这个命令了 go-filecoin
与官方已经编译好的二进制文件不一样,我这个代码更新一点,预编译好的版本是0.0.1版本
0.0.1版本在加入开发网络时有出错的情况,应该是代码还没完善吧。
注意:
go run ./build/*.go deps时遇到一些问题,网络状况不是很好,连接经常中断,可以自己分步运行这些指令,在代码./build/main.go的115行~150行
#!/bin/bash
go get -u github.com/whyrusleeping/gx
go get -u github.com/whyrusleeping/gx-go
gx install
gx-go rewrite
go get -u github.com/alecthomas/gometalinter
gometalinter --install
go get -u github.com/stretchr/testify
go get -u github.com/xeipuuv/gojsonschema
go get -u github.com/ipfs/iptb
go get -u github.com/docker/docker/api/types
go get -u github.com/docker/docker/api/types/container
go get -u github.com/docker/docker/client
go get -u github.com/docker/docker/pkg/stdcopy
go get -u github.com/ipsn/go-secp256k1
go get -u github.com/json-iterator/go
go get -u github.com/prometheus/client_golang/prometheus
go get -u github.com/prometheus/client_golang/prometheus/promhttp
go get -u github.com/jstemmer/go-junit-report
go get -u github.com/pmezard/go-difflib/difflib
./scripts/install-rust-proofs.sh
./scripts/install-bls-signatures.sh
./proofs/bin/paramcache
./scripts/copy-groth-params.sh
在上文中
curl https://sh.rustup.rs -sSf | sh
apt install -y jq libclang-dev clang
不能改变顺序,这里涉及到依赖的版本问题,apt install 时会安装Rust,但是不是我们想要的版本,先安装rust,在apt,可以避免版本依赖问题。
使用已经编译好的二进制文件
wget https://github.com/filecoin-project/go-filecoin/releases/download/0.0.1/filecoin-Linux.tar.gz
tar -zxvf filecoin-Linux.tar.gz
cp filecoin/go-filecoin /usr/local/bin/
加入网络
由于filecoin还处于开发阶段,默认运行命令go-filecoin bootstrap ls 什么都没有,想要手动添加启动连接节点等设置。
#!/bin/bash
rm -rf ~/.filecoin
go-filecoin init --devnet-user --genesisfile=http://user.kittyhawk.wtf:8020/genesis.car
go-filecoin daemon
注意这里go-filecoin daemon和ipfs daemon一样,会占用一个会话,这样可以做出服务启动:
vim /lib/systemd/system/filecoin.service
我已经将编译好的go-filecoin放入/usr/local/bin/目录,
cp ${GOPATH}/bin/go-filecoin /usr/local/bin/go-filecoin
[Unit]
Description=FileCoin
[Service]
ExecStart=/usr/local/bin/go-filecoin daemon
Restart=always
User=root
Group=root
[Install]
WantedBy=multi-user.target
service filecoin start
这时候我们运行go-filecoin swarm peers已经可以看到已经链接上的其他对等节点。
我们来设置一个昵称,地址不是这么好识别的,有一个昵称可以区分我,目前只能使用小写字母。
设置昵称推送的地址,这样他就可以记录我在网路上了。
go-filecoin config heartbeat.nickname "billimba"
go-filecoin config heartbeat.beatTarget "/dns4/stats-infra.kittyhawk.wtf/tcp/8080/ipfs/QmUWmZnpZb6xFryNDeNU7KcJ1Af5oHy7fB9npU67sseEjR"
进入 https://stats.kittyhawk.wtf/ 查看我自己。
看到我自己了。
注意:
运行go-filecoin daemon后会去同步区块,这时cpu是100%的,应该在验证块吧,在网页上看到自己的Block Height是30,等了很久没有上涨,于是我放了一个晚上,第二天已经同步上了,Block Height已经很别人一样了,同步到最新的区块了。
昨天已经完成了go-filecoin的编译,文件大小52M,拿着这个bin文件就可以去跑filecoin的节点了。
root@imba:~# go-filecoin
USAGEgo-filecoin - A decentralized storage networkgo-filecoin [--cmdapiaddr=<cmdapiaddr>] [--repodir=<repodir>] [--encoding=<encoding> | --enc] [--help] [-h]SUBCOMMANDSSTART RUNNING FILECOINgo-filecoin init - Initialize a filecoin repogo-filecoin config <key> [<value>] - Get and set filecoin config valuesgo-filecoin daemon - Start a long-running daemon processgo-filecoin wallet - Manage your filecoin walletsgo-filecoin address - Interact with addressesSTORE AND RETRIEVE DATAgo-filecoin client - Make deals, store data, retrieve datago-filecoin retrieval-client - Manage retrieval client operationsMINEgo-filecoin miner - Manage a single miner actorgo-filecoin mining - Manage all mining operations for a nodeVIEW DATA STRUCTURESgo-filecoin chain - Inspect the filecoin blockchaingo-filecoin dag - Interact with IPLD DAG objectsgo-filecoin show - Get human-readable representations of filecoin objectsNETWORK COMMANDSgo-filecoin bootstrap - Interact with bootstrap addressesgo-filecoin id - Show info about the network peersgo-filecoin ping <peer ID>... - Send echo request packets to p2p network membersgo-filecoin swarm - Interact with the swarmACTOR COMMANDSgo-filecoin actor - Interact with actors. Actors are built-in smart contracts.go-filecoin paych - Payment channel operationsMESSAGE COMMANDSgo-filecoin message - Manage messagesgo-filecoin mpool - Manage the message poolTOOL COMMANDSgo-filecoin log - Interact with the daemon event log output.go-filecoin version - Show go-filecoin version information
启动连接节点
命令 go-filecoin bootstrap ls
显示启动连接节点列表,这里为手动指定的user.kittyhawk.wtf节点
root@imba:~# go-filecoin bootstrap
USAGEgo-filecoin bootstrap - Interact with bootstrap addressesgo-filecoin bootstrapSUBCOMMANDSgo-filecoin bootstrap ls - Use 'go-filecoin bootstrap --help' for more information about this command.root@imba:~# go-filecoin bootstrap ls
&{[/dns4/user.kittyhawk.wtf/tcp/9000/ipfs/Qmd6xrWYHsxivfakYRy6MszTpuAiEoFbgE1LWw4EvwBpp4 /dns4/user.kittyhawk.wtf/tcp/9001/ipfs/QmXq6XEYeEmUzBFuuKbVEGgxEpVD4xbSkG2Rhek6zkFMp4 /dns4/user.kittyhawk.wtf/tcp/9002/ipfs/QmXhxqTKzBKHA5FcMuiKZv8YaMPwpbKGXHRVZcFB2DX9XY /dns4/user.kittyhawk.wtf/tcp/9003/ipfs/QmZGDLdQLUTi7uYTNavKwCd7SBc5KMfxzWxAyvqRQvwuiV /dns4/user.kittyhawk.wtf/tcp/9004/ipfs/QmZRnwmCjyNHgeNDiyT8mXRtGhP6uSzgHtrozc42crmVbg]}
查看自己的id
命令 go-filecoin id
root@imba:~# go-filecoin id
{"Addresses": ["/ip4/127.0.0.1/tcp/6000/ipfs/QmZFBFbfsGUfULZszVfdDVKE3xdsqCDeGyiuvYkPLkNCAH","/ip4/172.16.3.1/tcp/6000/ipfs/QmZFBFbfsGUfULZszVfdDVKE3xdsqCDeGyiuvYkPLkNCAH"],"ID": "QmZFBFbfsGUfULZszVfdDVKE3xdsqCDeGyiuvYkPLkNCAH"
}
ping
命令 go-filecoin ping
功能和icmp协议的ping一样,但是IP层面是透明的,p2p软件嘛,就是这样的。
root@imba:~# go-filecoin ping
ipfs: Reading from /dev/stdin; send Ctrl-d to stop.
QmW4Z8p7FCspLV1FeTRW6uCNApUXqkm8xYYw4yuBnqBGeB
PING <peer.ID Qm*nqBGeB>
Pong received: time=403.07 ms
Pong received: time=391.73 ms
Pong received: time=379.68 ms
^C
root@imba:~# go-filecoin ping QmW4Z8p7FCspLV1FeTRW6uCNApUXqkm8xYYw4yuBnqBGeB
PING <peer.ID Qm*nqBGeB>
Pong received: time=410.90 ms
Pong received: time=397.93 ms
Pong received: time=402.41 ms
^C
连接流
命令 go-filecoin swarm
分3个命令
root@imba:~# go-filecoin swarm
USAGEgo-filecoin swarm - Interact with the swarmgo-filecoin swarm'go-filecoin swarm' is a tool to manipulate the libp2p swarm. The swarm is thecomponent that opens, listens for, and maintains connections to otherlibp2p peers on the internet.SUBCOMMANDSgo-filecoin swarm connect <address>... - Open connection to a given address.go-filecoin swarm findpeer <peerID>... - Find the multiaddresses associated with a Peer ID.go-filecoin swarm peers - List peers with open connections.Use 'go-filecoin swarm --help' for more information about this command.
go-filecoin swarm peers 查看自己连上的连接。
go-filecoin swarm findpeer <peerID> 使用Peer ID寻找address。
go-filecoin swarm connect <address> 去连接一个地址。
钱包相关
root@imba:~# go-filecoin wallet
USAGEgo-filecoin wallet - Manage your filecoin walletsgo-filecoin walletSUBCOMMANDSgo-filecoin wallet addrs - Interact with addressesgo-filecoin wallet balance <address> - go-filecoin wallet export <addresses>... - go-filecoin wallet import <walletFile> - Use 'go-filecoin wallet --help' for more information about this command.
root@imba:~# go-filecoin wallet addrs
USAGEgo-filecoin wallet addrs - Interact with addressesgo-filecoin wallet addrsSUBCOMMANDSgo-filecoin wallet addrs lookup <address> - go-filecoin wallet addrs ls - go-filecoin wallet addrs new - Use 'go-filecoin wallet addrs --help' for more information about this command.
go-filecoin wallet addrs ls 显示自己的地址列表。
go-filecoin wallet addrs new 新建一个地址。
//TODO 未知 go-filecoin wallet addrs lookup
go-filecoin wallet balance <address> 查询余额。
go-filecoin wallet export <addresses> 导出密钥对。
go-filecoin wallet import <walletFile> 导入密钥对文件。
区块链
root@imba:~# go-filecoin chain
USAGEgo-filecoin chain - Inspect the filecoin blockchaingo-filecoin chainSUBCOMMANDSgo-filecoin chain head - Get heaviest tipset CIDsgo-filecoin chain ls - List blocks in the blockchainUse 'go-filecoin chain --help' for more information about this command.
go-filecoin chain ls 查看所有块
go-filecoin chain head 查看块头
IPLD源数据
root@imba:~# go-filecoin dag
USAGEgo-filecoin dag - Interact with IPLD DAG objects.go-filecoin dagSUBCOMMANDSgo-filecoin dag get <ref> - Get a DAG node by its CIDUse 'go-filecoin dag --help' for more information about this command.
查看区块内容
root@imba:~# go-filecoin show
USAGEgo-filecoin show - Get human-readable representations of filecoin objectsgo-filecoin showSUBCOMMANDSgo-filecoin show block <ref> - Show a filecoin block by its CIDUse 'go-filecoin show --help' for more information about this command.root@imba:~# go-filecoin show block zDPWYqFD7zTH4Ato2vpcVXjKpuHSAZujSLQRBQfZXe5GWsD9thZx
Block Details
Miner: fcqnmc3x995uxvh2xjjl3h4d8nt3c0w50lgu4f7ts
Weight: 3190.000
Height: 30
Nonce: 0
root@imba:~# go-filecoin show block zDPWYqFCutuHwRZhGXzji9L4eHeoFxxNCxCruGjWje36aAvbK2XV
Block Details
Miner: fcqqqqqqqqqqqqqqqqqqqqqyptunp
Weight: 0.000
Height: 0
Nonce: 0
root@imba:~# go-filecoin show block zDPWYqFD1R4povAi2A9DZHXVvXc4Cku1NsLEawFCN5yVGjiwnjY8
Block Details
Miner: fcqnmc3x995uxvh2xjjl3h4d8nt3c0w50lgu4f7ts
Weight: 0.000
Height: 1
Nonce: 0
go-filecoin show block <ref> 结合go-filecoin chain使用
go-filecoin编译安装与命令解释相关推荐
- mysql 数据库安装命令_教你MySQL数据库的编译安装以及命令详解(5.7版本)
一.安装MySQL所需的环境依赖包 [root@localhost opt]# yum -y install gcc gcc-c++ make ncurses ncurses-devel bison ...
- Redis 编译安装 基础命令 服务优化 持久化
Redis Redis 基础 编译安装 Redis(来吧!展示!!) 基础命令!! Redis 数据持久化 RBD 配置文件展示 AOF 配置文件展示 Redis 性能管理 内存碎片率 内存使用率 回 ...
- mysql源码安装分析_MySQL源码分析(0):编译安装及调试(转)
编译安装 为了实现MySQL的更高级别的性能调优,我们通常需要理解其内部实现机制,并对其进行优化调试.在下面的系列中,我们会分别介绍MySQL的部分内部实现机制. 首先我们介绍如何从源代码部署一台My ...
- 用编译安装搭建自己的http服务器
这里介绍一下用编译安装的方式搭建http服务器: 首先安装本服务器需要用到的软件包有 :apr-1.5.0.tar.gz apr-util-1.5.3.tar.gz pcre-8.21.tar.b ...
- linux php7.2编译安装,Linux下编译安装php7.2
准备工作 所有操作需要在root用户下 安装路径: /usr/local/php 安装PHP 首先要安装如下依赖包 $ yum install -y gcc gcc-c++ make zlib zl ...
- 基于openEuler的OpenSSL编译安装和编程基础
文章目录 基于openEuler的OpenSSL编译安装和编程基础 OpenSSL编译安装 OpenSSL命令的使用 OpenSSL编程 简单测试 BASE64算法 作业 参考资料 基于openEul ...
- 安装及管理程序(yum搭建本地源,了解rmp命令,查询卸载软件包,编译安装的过程)
文章目录 安装及管理程序 前言 linux命令与应用程序的关系 典型应用程序的目录结构 常见的软件包封装类型 查询RPM软件包信息 rpm概述 RPM机制封装命令格式 查询RPM软件包信息 查询未安装 ...
- php 编译ext目录下的,PHP编译安装后的目录和文件解释?
大家是通过什么方式了解php编译安装后生成的目录及文件的含义和解释的?是否有专门的文档解释这一方面? 这里只贴目录 php7.2.0 ├── bin ├── etc │ └── php-fpm.d ...
- mysql 安装dso命令_使用tengine DSO 来动态编译安装第三方模块(Lua
在使用nginx时,需要增加或者改动一个模块,都需要重新编译nginx文件.最近使用了tengine,它提供的DSO工具来动态加载模块.本例测试需要动态增加lua-nginx模块,记录一下安装过程. ...
最新文章
- 员工工号怎么编码_华为员工感慨:工号就留在这了,感谢公司给我自己写墓志铭的机会...
- 关于restful协议很多人的误解
- poj 1634 Who's the boss?
- SQL Server 提高创建索引速度的 2 个方法
- AspectJ学习笔记
- 介绍Spring Cloud Stream与RabbitMQ集成
- http://bsideup.blogspot.com/2015/04/spring-boot-thrift-part3.html
- [Example of Sklearn] - Example
- 2020版PS基础入门视频教程全集
- Word 尾部空格添加下划线
- matlab正激变换器,12个步骤设计恒流正激式开关电源
- 2017年终总结——恍恍惚惚又一年
- c语言数学函数指数,C语言数学函数参考表
- 【洛谷】P1138 第k小整数
- Android 显示大尺寸图片
- Found multiple @SpringBootConfiguration annotated classes
- AES种子秘钥构造一个完整的秘钥编排方案
- 【转】Keil、uVision、RealView、MDK、Keil C51之间的区别比较
- STM32系统时钟详解
- 算法学习-素数与合数小结