Wener Notes

IPFS

约 2 分钟阅读
标签:协议
  • the InterPlanetary File System
  • ipfsGitHub Orgipfsthe InterPlanetary File System · ipfs · ipfs.pics · Distributed image hosting · ipfstube · Why · 提供块级去重, 使得总体数据量得到压缩 · 参考笔记:IPFS
  • ipfs.picsGitHubipfspics/ipfspics-serverthe InterPlanetary File System · ipfs · ipfs.pics · Distributed image hosting · ipfstube · Why · 提供块级去重, 使得总体数据量得到压缩 · 参考笔记:IPFS
    • Distributed image hosting
  • ipfstubeGitHubdownload13/ipfstubethe InterPlanetary File System · ipfs · ipfs.pics · Distributed image hosting · ipfstube · Why · 提供块级去重, 使得总体数据量得到压缩 · 参考笔记:IPFS
  • Why
  • 端口
    • 4001 - Swarm TCP
    • 4002 - Swarm uTP
    • 5001 - API
      • /webui Web 管理端
    • 8080 - Gateway
    • 8081 - Swarm Websockets
  • 参考
  • IPFS 公共网关检测
  • 优势
    • 支持 gateway - 可以通过 HTTP 直接访问
    • 支持 MFS/虚拟目录
    • 目标是替代 internet 而不是单纯的 P2P 文件共享
    • ipns 替代 dns,ipfs 替代 internet
  • 劣势
    • IPFS 网络相对 torrent 没那么成熟
      • 意味着节点少
      • 资源少
    • 文件分发较慢
    • 开发公司重心转向 filecoin
  • 参考
bash
# macOS
brew install ipfs

# https://docs.ipfs.io/reference/api/cli/
# 生成配置文件
# 默认位于 $HOME/.ipfs 可通过 IPFS_PATH 更改
export IPFS_PATH=$PWD/repo
# 也可以使用 --config 或 -c 指定
ipfs init

# 获取配置
ipfs config -c $PWD/repo --json Addresses.API
# 修改配置
# 默认只监听 127.0.0.1
ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001

# 启动服务端
ipfs daemon

# 可使用 --api 指定远程接口
# 查看节点
ipfs --api /ip4/127.0.0.1/tcp/5001 swarm peers

# 容器环境中使用 ipfs
docker run --rm -it -v $PWD:/host --entrypoint sh --workdir /host ipfs/go-ipfs

# 启动服务
# -e IPFS_LOGGING=debug 显示调试日志
docker run -it --rm \
   -v $PWD/repo:/data/ipfs \
   -p 8080:8080 -p 4001:4001 -p 5001:5001 \
   --name ipfs_host ipfs/go-ipfs


# 生成 hash 不添加文件 - HASH 对应 IPLD file data
echo 'Hello IPFS!' | ipfs add -nq

# MFS 里文件的 hash - 是一个 LINK - HASH 对应 IPLD 多个 file block - 最后的一个 block 对应 raw 数据 - 相同数据但不同 hsah
ipfs files stat /myfile

# cp 可以支持从 add 的复制到 mfs
ipfs files cp /ipfs/$(echo 'Hello IPFS!' | ipfs add -q) /hello.txt
ipfs files read /hello.txt

libp2p

功能目的实现
使用数据applicationsIPFS
定义数据naming
merkledag
IPNS
IPLD
移动数据exchange
routing
network
libp2p

ipld/specs/ipldGitHub Fileipld/specs/ipld blog.cloudflare.com/distributed-web-gateway developers.cloudflare.com/distributed-web/ipfs-gateway

filestore

bash
# 启用特性
ipfs config --json Experimental.FilestoreEnabled true

gateway

bash
ipfs swarm connect $peer
ipfs bootstrap add $peer

关联信息

反向链接、本文链接的其他页面和外部资料。

References

GitHub10 条
其他外链6 条
最近更新commit f7c7613Edit

On this page