filecoin

【go-filecoin】 编译安装

安装环境

  • 系统:使用的是ubuntu 18.03.1 64位版本
  • go语言环境(Go >= v1.11.2)
  • Rush环境(Rust >= v1.31.0 and cargo)
  • pkg-config工具(pkg-config)
  • 添加环境变量,文件/etc/profile
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.gz

curl https://sh.rustup.rs -sSf | sh

apt install -y pkg-config cargo
apt install -y jq libclang-dev clang

echo $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

# 首先构建二进制文件
go run ./build/*.go build

# Install go-filecoin to ${GOPATH}/bin
go run ./build/*.go install

# 运行测试
go run ./build/*.go test

# 构建和测试可以结合起来!
go run ./build/*.go best

编译运行

编译运行结果
go-filecoin
  • 使用已经编译好的二进制文件
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
  • service filecoin start 运行go-filecoin swarm peers已经可以看到已经链接上的其他对等节点。


    image
  • 我们来设置一个昵称,地址不是这么好识别的,有一个昵称可以区分我,目前只能使用小写字母。
    设置昵称推送的地址,这样他就可以记录我在网路上了。
heartbeat.nickname "FILECOIN"
go-filecoin config heartbeat.beatTarget "/dns4/stats-infra.kittyhawk.wtf/tcp/8080/ipfs/QmUWmZnpZb6xFryNDeNU7KcJ1Af5oHy7fB9npU67sseEjR"
4
  • 运行go-filecoin daemon后会去同步区块,这时cpu是100%的,应该在验证块吧,在网页上看到自己的Block Height是30,同步到最新的区块.
  • 完成go-filecoin的编译,拿着这个bin文件就可以去跑filecoin的节点了。
root@imba:~# go-filecoin 
USAGE
  go-filecoin - A decentralized storage network

  go-filecoin [--cmdapiaddr=<cmdapiaddr>] [--repodir=<repodir>] [--encoding=<encoding> | --enc] [--help] [-h]

SUBCOMMANDS
  START RUNNING FILECOIN
    go-filecoin init                   - Initialize a filecoin repo
    go-filecoin config <key> [<value>] - Get and set filecoin config values
    go-filecoin daemon                 - Start a long-running daemon process
    go-filecoin wallet                 - Manage your filecoin wallets
    go-filecoin address                - Interact with addresses
  
  STORE AND RETRIEVE DATA
    go-filecoin client                 - Make deals, store data, retrieve data
    go-filecoin retrieval-client       - Manage retrieval client operations
  
  MINE
    go-filecoin miner                  - Manage a single miner actor
    go-filecoin mining                 - Manage all mining operations for a node
  
  VIEW DATA STRUCTURES
    go-filecoin chain                  - Inspect the filecoin blockchain
    go-filecoin dag                    - Interact with IPLD DAG objects
    go-filecoin show                   - Get human-readable representations of filecoin objects
  
  NETWORK COMMANDS
    go-filecoin bootstrap              - Interact with bootstrap addresses
    go-filecoin id                     - Show info about the network peers
    go-filecoin ping <peer ID>...      - Send echo request packets to p2p network members
    go-filecoin swarm                  - Interact with the swarm
  
  ACTOR COMMANDS
    go-filecoin actor                  - Interact with actors. Actors are built-in smart contracts.
    go-filecoin paych                  - Payment channel operations
  
  MESSAGE COMMANDS
    go-filecoin message                - Manage messages
    go-filecoin mpool                  - Manage the message pool
  
  TOOL COMMANDS
    go-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
USAGE
  go-filecoin bootstrap - Interact with bootstrap addresses

  go-filecoin bootstrap

SUBCOMMANDS
  go-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
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
root@imba:~# go-filecoin swarm
USAGE
  go-filecoin swarm - Interact with the swarm

  go-filecoin swarm

  'go-filecoin swarm' is a tool to manipulate the libp2p swarm. The swarm is the
  component that opens, listens for, and maintains connections to other
  libp2p peers on the internet.

SUBCOMMANDS
  go-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> 去连接一个地址。

【go-filecoin】代币获取、储存挖矿

环境准备

  • 一个纯净的Ubuntu18.04.2系统
  • 编译好的go-filecoin二进制文件(52M)
  • 互联网接入
  • 将本机的6000端口做公网映射【非必须】。
  • 一切就绪后将go-filecoin二进制文件放入系统目录 /usr/local/bin/,这样在任何目录下这个命令都可以使用了。

查看当前的区块高度

  • 获取最高区块的索引值
go-filecoin chain head
  • 查看这个索引值得内容
go-filecoin show block <____>
  • 可以查看到我已经同步到24110高度了
5

申请代币

  • 打开网站 http://user.kittyhawk.wtf:9797 填写自己的地址

  • 自己的地址通过go-filecoin wallet addrs ls来查看,点击提交后会给你一个MESSAGE_CID,侦听这个消息就可以知道是否已经被打包了(go-filecoin message wait ${MESSAGE_CID}),等到消息发送后,再回过头来看自己的余额,发现已经有了900FIL,目前一个地址24小时内只能提交一次申请,申请到900FIL

开始挖矿

go-filecoin miner create 10 1 --price=0 --limit=1000 --peerid `go-filecoin id | jq -r '.ID'`
示例
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 160,026评论 4 364
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,655评论 1 296
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 109,726评论 0 244
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 44,204评论 0 213
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,558评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,731评论 1 222
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,944评论 2 314
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,698评论 0 203
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,438评论 1 246
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,633评论 2 247
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,125评论 1 260
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,444评论 3 255
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,137评论 3 238
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,103评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,888评论 0 197
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,772评论 2 276
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,669评论 2 271

推荐阅读更多精彩内容