IPFS是什么

简单来说,IPFS(全称为 InterPlanetary File System),是一种永久性,去中心化,又可共享文件的分布式文件系统,是一种可通过地址寻址、版本话、进行点对点超媒体的分布式协议。

可寻址:通过文件内容来生成唯一的Hash值来标识文件,而不是通过文件保存位置来标识。相同内容的文件在系统中只会存在一份,节约存储空间

版本化:可追溯文件的修改历史(类似Git、SVN)

点对点超媒体(P2P):通过Peer To Peer 保存各式各样的类型数据,将所有具有相同文件系统的计算设备连接在一起(全球性)

IPFS的大致工作原理

  1. 该系统中每个文件都被进行 Hash 处理,得到Hash值,生成数字指纹
  2. 查找文件时,IPFS 通过使用一个分布式哈希表,可以快速找到拥有数据的节点进行检索,并使用哈希验证其是否是正确的数据,找到想要的文件。(在 /ipfs 和 /ipns 下挂载全球文件系统)
  3. IPFS 通过网络删除重复具有相同哈希值的文件,通过计算是可以判断哪些文件是冗余重复的。并跟踪每个文件的版本历史记录
  4. 可作为数据库使用:可直接操作 Merkle DAG,拥有 IPFS 提供的版本化、缓存以及分布式特性
  5. 每个网络节点只存储它感兴趣的内容,以及一些索引信息,可进行通讯加密,便于识别,便于查找
  6. 更多原理可以细看IPFS《ipfs-p2p-file-system》技术白皮书

IPFS的简单部署及安装

在官网下载合适的go-ipfs版本,官网地址为:https://ipfs.io (国内需VPN进行访问),安装教程:https://ipfs.io/docs/

本文简单阐述一下Windows安装流程:

1、下载


2、安装目录结构


3、打开CMD窗口,输入 ipfs --help


4、就可以开始IPFS之旅了。init the repo 进行初始化本地仓库,生成文件系统存储的Hash节点

> ipfs init
initializing ipfs node at /Users/jbenet/.go-ipfs
generating 2048-bit RSA keypair...done
peer identity: Qmcpo2iLBikrdf1d6QU6vXuNb6P7hwrbNPW9kLAH8eG67z
to get started, enter:

  ipfs cat /ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme

5、现在,你就可以打开readme,输入命令:

ipfs cat /ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme
You should see something like this:

Hello and Welcome to IPFS!

██╗██████╗ ███████╗███████╗
██║██╔══██╗██╔════╝██╔════╝
██║██████╔╝█████╗  ███████╗
██║██╔═══╝ ██╔══╝  ╚════██║
██║██║     ██║     ███████║
╚═╝╚═╝     ╚═╝     ╚══════╝

If you're seeing this, you have successfully installed
IPFS and are now interfacing with the ipfs merkledag!

 -------------------------------------------------------
| Warning:                                              |
|   This is alpha software. use at your own discretion! |
|   Much is missing or lacking polish. There are bugs.  |
|   Not yet secure. Read the security notes for more.   |
 -------------------------------------------------------

Check out some of the other files in this directory:

  ./about
  ./help
  ./quick-start     <-- usage examples
  ./readme          <-- this file
  ./security-notes

You can explore other objects in there. In particular, check out quick-start:

ipfs cat /ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/quick-start
Which will walk you through several interesting examples.

IPFS的详细API与命令操作

参见官网:https://ipfs.io/docs/commands/https://ipfs.io/docs/api/

欢迎交流~



Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐