go-filecoin 0.5.8

go-filecoin

  • 1,安装 go-filecoin
  • 2,存储矿工
  • 3,存储数据进行交易
  • 4,报错
  • 5,交易时间
  • 6,创建服务

1,安装 go-filecoin

  • 安装filecoin-0.5.6-Linux.tar.gz
# tar -zxvf filecoin-0.5.6-Linux.tar.gz
# cd filecoin/
# ls -l
total 67344
-rwxr-xr-x 1 3434 3434 48859448 9月  25 08:49 go-filecoin
-rwxr-xr-x 1 3434 3434 20096416 9月  25 08:49 paramcache
# cd /var/tmp/
# mkdir filecoin-proof-parameters
# echo 'export PATH="/root/filecoin:$PATH"' >> ~/.bashrc
# source ~/.bashrc
# cd filecoin/
# ./paramcache
  • 安装filecoin-0.5.7-Linux.tar.gz
# pwd
/
# ls -lah | grep filecoin

# tar -zxvf filecoin-0.5.7-Linux.tar.gz -C ~

  • 设置环境变量
# cat ~/.bashrc
export PATH="/root/filecoin":$PATH
# source ~/.bashrc
# echo 'export PATH="/root/filecoin":$PATH' >> ~/.bashrc
# source ~/.bashr
# which go-filecoin
/root/filecoin/go-filecoin
  • 初始化节点
go-filecoin init --devnet-user --genesisfile=https://genesis.user.kittyhawk.wtf/genesis.car
  • --sectordir指定存储目录
go-filecoin init --devnet-user --genesisfile=https://genesis.user.kittyhawk.wtf/genesis.car --sectordir=/storage
  • 后台运行节点
nohup go-filecoin daemon >> /var/log/filecoin.log 2>&1 &
go-filecoin daemon >> /var/log/filecoin.log 2>&1 &
  • 节点命名
# go-filecoin config heartbeat.nickname "test"
# go-filecoin config heartbeat.nickname
"test"
  • 节点添加到web网络统计( 需要重启守护进程)
go-filecoin config heartbeat.beatTarget "/dns4/backend-stats.kittyhawk.wtf/tcp/8080/ipfs/QmUWmZnpZb6xFryNDeNU7KcJ1Af5oHy7fB9npU67sseEjR"
  • 水龙头获取测试代币
curl -X POST -F "target=$(go-filecoin address ls)" "http://user.kittyhawk.wtf:9797/tap"
  • 获取成功返回 Message CID
# curl -X POST -F "target=$(go-filecoin address default)" "http://user.kittyhawk.wtf:9797/tap"
Success! Message CID: bafy2bzacec4u7aa63nbtni7c2l5xtpqwnmxtxbhallcf35xsj6s2lcrxayim2
  • 查看钱包金额
go-filecoin wallet balance `go-filecoin address ls`
  • go-filecoin address
  go-filecoin address default          
  go-filecoin address lookup 
go-filecoin address ls go-filecoin address new
  • 查看块高度
go-filecoin show block $(go-filecoin chain head | head -n 1)
go-filecoin show block $(go-filecoin chain head | head -n 1) | grep Height | awk '{print $2}'
  • Error actor not found
# go-filecoin mining status
Error: query ProvingPeriod method failed: querymethod returned an error: failed to get To actor: actor not found

2,存储矿工

  • 创建矿工
go-filecoin miner create 100 --gas-price=0.001 --gas-limit=300
  • 查看矿工状态
go-filecoin mining status
  • 开始挖矿
go-filecoin mining start
  • 查看节点ID、查看余额、同步区块高度、矿工角色状态、矿工地址、存储价格
go-filecoin id | jq -r '.["ID"]' && go-filecoin wallet balance $(go-filecoin address ls) && go-filecoin show block $(go-filecoin chain head | head -n 1) | grep Height && go-filecoin mining status | grep Active && cat /root/.filecoin/config.json | jq .'["mining"]'
  • 节点ID和矿工地址
go-filecoin mining address && go-filecoin id | jq .'["ID"]'
  • 设置存储价格(等待了2分钟)
go-filecoin miner set-price --gas-price=0.001 --gas-limit=1000 0.000000001 2880
  • 报错(可能报错,需要等待一会)
# go-filecoin miner set-price --gas-price=0.001 --gas-limit=1000 0.000000001 2880
Error: couldn't send message: failed to add message to message pool: validation error adding message to pool: message nonce (104) is too much greater than actor nonce (1)
  • 查看配置信息storagePrice存储价格
  • cat /root/.filecoin/config.json
cat /root/.filecoin/config.json | jq .'["mining"]'
"mining": {
		"minerAddress": "t2f",
		"autoSealIntervalSeconds": 120,
		"storagePrice": "0.000000001"
	},
  • 查询价格
# go-filecoin client list-asks | grep t2tjb3557lel4qrvn63snngkr3duvx7u2kwbghaxa
t2tjb3557lel4qrvn63snngkr3duvx7u2kwbghaxa 000 0.000000001 29847

3,存储数据进行交易

echo "Hi my name is zZZ" > hello.txt
# go-filecoin client import hello.txt
QmPH17EeXR43Wv22FPz27X4P2Gm7PDhp8SX7zE6tGqDZ61
# go-filecoin client cat QmPH17EeXR43Wv22FPz27X4P2Gm7PDhp8SX7zE6tGqDZ61
Hi my name is zZZ
# go-filecoin client import hello.txt
QmPJMstUFmkYe5gMdiPZWqiHygfH6pHpuGkzoT2TLaGRMw
# go-filecoin client cat QmPJMstUFmkYe5gMdiPZWqiHygfH6pHpuGkzoT2TLaGRMw
hi my name is vVv

  • 指定矿工交易
  • go-filecoin client propose-storage-deal
# go-filecoin client propose-storage-deal t2tbxe6abh46gwhnvjpkhjgxktt7ygxaxquw5gpoy QmPJMstUFmkYe5gMdiPZWqiHygfH6pHpuGkzoT2TLaGRMw 000 2880
State:   accepted
Message:
DealID:  bafy2bzacecikq7bjuleknuoufzvjhrf4ws5udimnx2ffrnonbs5ahkwhsyt4m
  • 存储交易
# go-filecoin client propose-storage-deal t2tjb3557lel4qrvn63snngkr3duvx7u2kwbghaxa QmcWKhv6tZ3MTtxERz9H5edh5Zjpuybo7mT9YZ2VqgxDw9 000 2880
+State:   accepted
Message:
DealID:  bafy2bzacecvaakd463zmhipatlqg2z3j3kwkn3kpysjpeqnri6j3dxneiqxnq
  • 客户端端查看交易记录
# go-filecoin deals list -m
# go-filecoin deals list -c
{
	"minerAddress": "t2tjb3557lel4qrvn63snngkr3duvx7u2kwbghaxa",
	"pieceCid": {
		"/": "QmcWKhv6tZ3MTtxERz9H5edh5Zjpuybo7mT9YZ2VqgxDw9"
	},
	"proposalCid": {
		"/": "bafy2bzacecvaakd463zmhipatlqg2z3j3kwkn3kpysjpeqnri6j3dxneiqxnq"
	},
	"state": "accepted"
}
  • 交易报错
Error: response check failed: deal rejected: payments start after deal start interval
  • 查看交易状态
# go-filecoin client query-storage-deal bafy2bzacecikq7bjuleknuoufzvjhrf4ws5udimnx2ffrnonbs5ahkwhsyt4m
Status: staged
Message:
  • 等待几分钟交易完成 Status: complete
# go-filecoin client query-storage-deal bafy2bzacecikq7bjuleknuoufzvjhrf4ws5udimnx2ffrnonbs5ahkwhsyt4m
Status: complete
Message:
  • 矿工节点扇区存储
265M
  • 矿工节点查看交易信息
# go-filecoin deals list --miner
{
	"minerAddress": "t2tbxe6abh46gwhnvjpkhjgxktt7ygxaxquw5gpoy",
	"pieceCid": {
		"/": "QmPJMstUFmkYe5gMdiPZWqiHygfH6pHpuGkzoT2TLaGRMw"
	},
	"proposalCid": {
		"/": "bafy2bzacecikq7bjuleknuoufzvjhrf4ws5udimnx2ffrnonbs5ahkwhsyt4m"
	},
	"state": "staged"
}
  • 矿工Power查看
# go-filecoin mining status
Mining Status
Active:     true
Address:    t2tjb3557lel4qrvn63snngkr3duvx7u2kwbghaxa
Owner:      t1xtc7frd3eyh6bih66eqxmjoafgicvdlz7qsqafa
Collateral: 0
Power:      0 / 35232690470912

Proving Period
Start:         0
End:           0
Proving Set:   []
  • 矿工交易状态
# go-filecoin deals list -c
# go-filecoin deals list -m
{
	"minerAddress": "t2tjb3557lel4qrvn63snngkr3duvx7u2kwbghaxa",
	"pieceCid": {
		"/": "QmcWKhv6tZ3MTtxERz9H5edh5Zjpuybo7mT9YZ2VqgxDw9"
	},
	"proposalCid": {
		"/": "bafy2bzacecvaakd463zmhipatlqg2z3j3kwkn3kpysjpeqnri6j3dxneiqxnq"
	},
	"state": "staged"
}

4,报错

  • 矿工Active: false
# go-filecoin mining status
Mining Status
Active:     false
# go-filecoin mining stop
Stopped mining
# go-filecoin mining start
Started mining
# go-filecoin mining status
Mining Status
Active:     true

5,交易时间

  • 一个小文件交易请求大概需要40秒

6,创建服务

# cd /lib/systemd/system
# touch filecoin.service
# vim filecoin.service
# cat filecoin.service
[Unit]
Description=go-filecoin daemon
[Service]
ExecStart=/root/filecoin/go-filecoin daemon
Restart=always
User=root
Group=root
[Install]
WantedBy=multi-user.target

# systemctl enable filecoin.service
# systemctl start filecoin.service
# systemctl status filecoin.service
  • 日志查看
# journalctl -u filecoin.service
# journalctl -u filecoin.service -f

参考:

  1. Get FIL from the Filecoin faucet
  2. go-filecoin V0.5.6 发布 / 命令更新
  3. Systemd 入门教程

你可能感兴趣的:(IPFS)