首页>参考读物>计算机科学与技术>软件与程序设计

IPFS原理与实践
作者 : 董天一 戴嘉乐 黄禹铭 著
出版日期 : 2019-07-17
ISBN : 978-7-111-62880-4
定价 : 89.00元
扩展资源下载
扩展信息
语种 : 简体中文
页数 : 255
开本 : 16
原书名 :
原出版社:
属性分类: 店面
包含CD : 无CD
绝版 : 未绝版
图书简介

本书由国内IPFS社区公认最权威的领袖撰写,从技术、原理与实战3个维度讲解了IPFS。
全书一共分为3个部分:
第一部分:准备篇(第1章)
从宏观角度简单介绍了IPFS的概念、价值以及与区块链的关系;
第二部分:原理篇(第2~5章)
分别深入讲解了IPFS的工作原理、底层基础、协议栈和架构。
第三部分:实战篇(第6~8章)——应用IPFS
讲解了IPFS应用开发的技术、方法,并配合有个综合性的案例。
第四部分:扩展篇(第9章)
前瞻性地讲解了IPFS与其他领域的知识的一些扩展。

图书特色

国内3位早期IPFS技术布道者撰写,IPFS&Filecoin创始人及官方团队强烈推荐
从实现原理和工程实践两个维度详细剖析IPFS和Filecoin

图书前言

缘起
我们在2017年下半年至2018年上半年期间,牺牲了大量的业余时间,一直在做IPFS这门新兴技术的相关解读、线下MeetUp工作。我们在知乎专栏和微信公众号上建立的《IPFS指南》是中国第一个系统、全面地介绍这门技术的中文资料站。机械工业出版社华章分社的杨福川老师在第一时间找到我们,希望我们能够为国内开发人员写一本IPFS技术相关的图书,方便国人更好地理解并应用这门技术。于是,便有了你手中的这本书。
为什么要写这本书
IPFS这门技术诞生于2014年,由协议实验室(Protocol Labs)创建。但是,直到2017年年中才逐渐走入大众视野,因为其能与区块链完美结合,所以使得其成为近几年最火热的技术之一。然而,国内却没有与IPFS技术相关、利于国人阅读、知识体系结构相对系统全面的中文学习资料。因此,我联系了当时在这个领域钻研摸索最多的几位布道者和专家,一起撰写了这本书,希望能帮助国内IPFS技术爱好者更加快速地学习、掌握、应用这门技术。
IPFS这门技术还在不断演化中,它引导的是一场真正的网络协议革命,是一种全球化思维的碰撞,是一种突破传统的海量数据共享的模式。IPFS可能不是这场革命的导火索,但是我认为,它至少能带领大家去学习和认识这种思维,这是一件非常有意义的事情。
读者对象
本书适合有一定区块链常识和基础,有软件开发能力,但是不了解IPFS,想学习IPFS的技术原理,并基于IPFS做相关开发工作的读者。主要包含以下人员:
IPFS技术爱好者;
网络协议技术爱好者;
分布式存储技术爱好者;
区块链技术爱好者;
区块链领域从业者;
开设相关课程的大专院校师生。
本书特色
首先,IPFS是在区块链技术蓬勃发展的情况下得到广泛认可的,本书除了针对IPFS技术本身进行讲解以外,还增加了大量区块链相关知识作为铺垫和补充,包括单独设立第5章来重点介绍IPFS的激励层—Filecoin区块链项目。
其次,本书不仅介绍了IPFS技术本身的细节,还加入了大量笔者在开发中总结的经验和技巧,并搭配了相关生态链中较新的软件开发工具和前沿的尖端技术。在技术深度和广度两个方面都兼顾得比较妥当,有明显的层次感。
再次,本书提供了大量的项目实例,这些项目实例能够帮助读者更好地理解IPFS技术和应对一些业务场景。
最后,本书是一本相对全面和系统地解读了IPFS和Filecoin技术的书籍,也是一本国内由相关领域中最早期的布道者、专家合力编写的中文权威书籍。
如何阅读本书
本书分为三大部分:
第1部分为基础篇,包括第1章。简单地介绍了IPFS的概念、优势和应用领域,旨在帮助读者了解一些基础背景知识,并从宏观层面来认识IPFS技术所具有的创新性。
第2部分为原理篇,包括第2~5章。从内部详细剖析IPFS的底层基础、协议栈构成,以及libp2p、Multi-Format、Filecoin等模块。
第3部分为实战篇,包括第6~8章。以工程化的方式,从基础至进阶,讲解了IPFS技术的实际使用,并通过讲解两个不同风格的项目案例,让读者了解不同语言实现的IPFS协议栈。
其中,第3部分以接近实战的实例来讲解工程应用,相比于前两部分更独立。如果你是一名资深用户,已经理解IPFS的相关基础知识和使用技巧,那么你可以跳过前两个部分,直接阅读第3部分。如果你是一名初学者,则务必从第1章的基础理论知识开始学习。
勘误和支持
由于作者的水平有限,加之IPFS等相关技术更新迭代快,书中难免会出现一些错误或者不准确的地方,恳请读者批评指正。为此,我们创建了存放本书相关资料和便于信息反馈的Github仓库https://github.com/daijiale/IPFS-and-Blockchain-Principles-and-Practice。如果大家在阅读本书的过程中遇到任何问题,可以通过上述渠道以Issue的形式反馈给我们,我们将在线上为读者提供解答。期待能够得到你们的真挚反馈。本书的相关源码和资料文件除了可以从华章网站下载外,还可以从上述渠道下载。
致谢
首先要感谢协议实验室开创的这款具有划时代意义的新型网络协议。
其次要感谢机械工业出版社华章分社的杨福川、孙海亮、李良三位老师为本书顺利出版所付出的努力,没有他们的支持,本书无法如期顺利完成。
同时感谢知乎专栏《IPFS指南》及国内因IPFS技术自发组织而成的众多爱好者社区,他们对IPFS技术的执着和探索是我们创作的动力,在和他们的交流中我们发现了本书的价值和创作素材。
感谢我的合作者董天一前辈,他在计算机系统、软件工程、经济学基础、博弈论、区块链存储方面学识渊博,使我在与他合作著书的过程中不断进步。同时,董天一前辈对本书的审稿和校稿工作也做出了重要的贡献。
感谢我的另一位合作者黄禹铭,他在区块链学术领域积累丰厚,对本书的众多技术进行了详细的原理解读和分析,尤其是在第1章、第2章、第4章和第5章。
感谢新加坡国立大学Andrew Lim教授对本书的大力支持以及TangJing助理教授对我们技术上的指导。
谨以此书献给我最亲爱的家人,以及中国众多热爱IPFS和区块链技术的朋友们。

戴嘉乐

上架指导

计算机\程序设计

封底文字

This is a comprehensive and thorough guide to IPFS, Filecoin, libp2p and other related protocols. In it, you will learn how these systems work from the ground-up. Both beginners and experts are likely to find it very useful! Get started building your first IPFS application!
——Juan Benet IPFS和Filecoin创始人、协议实验室创始人

This book is a great resource for all developers interested in decentralized technologies. The overview of these systems, actionable guides to get started, and explanations of how these tools fit together are valuable resources for the entire community. Thanks so much to the authors for creating this important guide!
——Molly Mackinlay IPFS项目负责人

PPTV过去近十年的经验让我意识到P2P技术还有极大的潜力没被发掘。IPFS期望用去中心化的方式再造下一代互联网,这正是未被挖掘的潜力。读完此书我更坚信IPFS的设想是可能实现的。PPIO也是在建设下一代互联网协议,只是走的路线和IPFS不同,我依然坚信当年创办PPLive的初衷(后更名为PPTV),P2P change our lives。
——姚欣 PPLabs董事长、PPTV创始人、蓝驰创投合伙人

区块链领域是我们非常感兴趣的研究方向。除了讨论较多的扩容、隐私和安全问题,我们也意识到当前区块链架构下存在大量的存储冗余,这一方式长期来看不可持续。在研究过IPFS之后,我们意识到这可能是一个既能同时保留去中心化又能维持容错率的方案。我们也会继续研究这一个充满潜力的方向,为社会创造更大的价值。
——Andrew Lim 新加坡国立大学工业系统工程系主任

推荐序

Computing and the internet have transformed humanity. We live in an extraordinary time -- computers have amplified our capabilities and the internet has connected our species together. Software applications grant us all superpowers that our ancestors would have considered magical: we can access and search all information in seconds; we can talk face-to-face with anybody around the planet; we can broadcast our messages and speeches to everyone world-wide; and we have enhanced our minds with external computing and information storage. We have tremendous, awe-inspiring capabilities.
The properties of the internet determine our capabilities. All of these powers hinge on the properties of the internet -- if the internet breaks down, or is insecure, then so are our applications and our capabilities. We must ensure that the super-powers we have acquired continue to work, as our lives now depend on them. Most human coordination and collaboration happens over the internet-from our personal chats, to work emails, to industrial and cross-organization communication. Even hospitals, emergency services, and other systems rely on the internet. Our lives depend on how well the internet works! We must endeavor to make the internet more secure, efficient, resilient, and robust.
IPFS is upgrading the internet. We built IPFS, the InterPlanetary File System, to achieve this. IPFS is a hypermedia protocol that upgrades how we address and distribute content -- its key component is to replace Location Addressing (URLs) with Content Addressing (CID URIs). In the last few years, IPFS has created a powerful and robust application distribution platform, that millions of people benefit from world-wide. There are hundreds of thousands of computers running IPFS nodes today, distributing information and applications, and this number is growing quickly! There are encyclopedias, chat systems, marketplaces, video distribution platforms, knowledge management systems, package managers, developer tools, games, VR environments, and more. As more developers choose to develop applications or content with IPFS, more millions of people benefit world-wide. Are you going to help us upgrade the internet?
Filecoin will upgrade data storage and distribution. The next stage is to make a decentralized storage network, a public, internet-wide utility that helps us store and distribute our data efficiently, robustly, and cheaply. The goal of Filecoin is to build such a storage market, where storage providers (miners) can sell storage space over time, and clients can buy storage that is more efficient, more robust, and lower cost. This is achieved with the use of a blockchain, a token to mediate the value exchange and incent participation, smart contracts to mediate transactions, and more. Using the power of verifiable markets and game theory, we aim to make the world抯 largest, most resilient, and lowest cost storage network. At the time of this writing, Filecoin is under fast-paced development and headed towards its testnet and mainnet launches. This and the next few years are a great time to get involved! We are shaping the future of data storage and distribution, and you can help us make it even better.
I invite you to join this computing revolution! You can get involved by using applications powered with IPFS, or by building them yourself today. You can learn about Filecoin and join the community developing Filecoin and applications on top of it, or you can become a miner and sell storage to the network. You can build lower level applications on top of libp2p, and you can model content and its distribution with IPLD. You can use these technologies, and you can help build them.
This book is a great guide for you. Learning about all these technologies at once can be very confusing. I am thrilled that the authors have written this book, so it can guide you step by step. Though I have only been able to review a machine-translated version -- I found this to be an excellent and thorough guide for both new people just getting started, and experienced IPFS developers who want to understand the internals. It is a solid introduction and guide to IPFS, Filecoin, and all the related protocols. It contains a good overview of the systems and how they work. You will learn how our protocols use multihash, multiaddr, and other multiformats to be self-describing and future-proof. You will learn how libp2p connects computers together across a variety of transports, and makes it easy to build p2p protocols. You will learn how to model data with IPLD and content-address it with CIDs. You will learn how IPFS plugs all these protocols together into a decentralized web protocol, and how to use it to build applications. You will learn about the Filecoin protocol and how it will work. You will learn how all of these protocols work together to store, address, and move information. This book is a comprehensive and thorough guide -- I hope it serves you well! Though note an important warning: like all technology books, this is likely to become outdated as the systems continue to develop. Be sure to check online versions of the book, and the projects抎ocumentation websites. The concepts will remain the same -- and for that, this book will hopefully serve you well for a long time -- but the technical details will surely evolve, and you will want to check up-to-date documentation.
I hope you enjoy this book. I am very grateful to the authors for writing this book: your work will help so many others!
Juan Benet
IPFS和Filecoin创始人
协议实验室创始人

图书目录

推荐序
赞誉
前言
基础篇 认识IPFS
第1章 认识IPFS2
1.1 IPFS概述2
1.1.1 IPFS的概念和定义2
1.1.2 IPFS的起源4
1.2 IPFS与区块链的关系8
1.2.1 区块链基础8
1.2.2 区块链发展10
1.2.3 IPFS为区块链带来了什么改变14
1.2.4 Filecoin:基于IPFS技术的区块链项目15
1.3 IPFS的优势与价值16
1.3.1 IPFS的优势16
1.3.2 Filecoin与其他区块链存储技术的对比21
1.4 IPFS的应用领域23
1.5 本章小结25
原理篇 理解IPFS
第2章 IPFS底层基础28
2.1 分布式哈希表(DHT)28
2.1.1 Kademlia DHT29
2.1.2 Coral DSHT36
2.1.3 S/Kademlia DHT38
2.2 块交换协议(BitTorrent)41
2.2.1 BitTorrent术语含义42
2.2.2 P2P块交换协议43
2.2.3 阻塞策略44
2.3 版本控制(Git)46
2.4 自验证文件系统(SFS)54
2.4.1 SFS设计55
2.4.2 自验证文件路径57
2.4.3 用户验证58
2.4.4 密钥撤销机制58
2.5 Merkle DAG和Merkle Tree59
2.5.1 Merkle Tree60
2.5.2 Merkle DAG63
2.6 本章小结65
第3章 IPFS协议栈66
3.1 身份层(Identity)67
3.2 网络层(Network)68
3.3 路由层(Routing)69
3.4 交换层(Exchange)71
3.4.1 BitSwap协议71
3.4.2 BitSwap信用体系75
3.4.3 BitSwap策略75
3.4.4 BitSwap账单76
3.5 对象层(Object)77
3.6 文件层(File)79
3.7 命名层(Naming)83
3.7.1 IPNS:命名以及易变状态83
3.7.2 自验证命名83
3.7.3 人类友好名称84
3.8 本章小结85
第4章 IPFS模块解析86
4.1 Multi-Format86
4.1.1 Multi-Hash87
4.1.2 Multi-Base90
4.1.3 Multi-Addr92
4.1.4 Multi-Codec95
4.1.5 Multi-Stream 98
4.2 libp2p98
4.2.1 libp2p的功能99
4.2.2 libp2p核心原理101
4.2.3 libp2p的用途108
4.3 IPLD109
4.3.1 IPLD数据模型110
4.3.2 内容识别符(CID)112
4.3.3 CID解码规则115
4.4 本章小结116
第5章 Filecoin117
5.1 Filecoin项目简介117
5.1.1 Filecoin项目的起源117
5.1.2 Filecoin 项目的价值118
5.1.3 Filecoin的价值交换市场119
5.1.4 优化互联网的使用120
5.2 Filecoin与IPFS之间的关系120
5.3 Filecoin经济体系122
5.3.1 Filecoin 的分发与使用122
5.3.2 Filecoin 矿工收益结构123
5.4 Filecoin技术体系总览124
5.4.1 Filecoin系统基本概念125
5.4.2 Filecoin交易市场运行简介125
5.4.3 Filecoin区块链数据结构127
5.4.4 Filecoin 区块链运行原理129
5.5 去中心化存储网络协议(DSN)130
5.5.1 Put、Get、Manage操作130
5.5.2 拜占庭问题与存储错误133
5.5.3 DSN协议中的两类基础操作134
5.5.4 存储节点操作协议138
5.5.5 检索节点操作协议141
5.5.6 网络操作协议143
5.6 Filecoin交易市场145
5.6.1 存储市场146
5.6.2 检索市场148
5.7 Filecoin 区块链共识机制151
5.7.1 共识机制概述151
5.7.2 共识机制要解决的3个问题152
5.8 复制证明(PoRep)和时空证明(PoSt)157
5.8.1 存储证明的6种定义157
5.8.2 存储证明成员159
5.8.3 复制证明(PoRep)160
5.8.4 时空证明(PoSt)163
5.8.5 复制证明 PoRep和时空证明PoSt的实现164
5.9 网络攻击与防范173
5.10 其他特性176
5.10.1 Filecoin智能合约176
5.10.2 Bridge互联系统177
5.11 本章小结177
实战篇 应用IPFS
第6章 IPFS开发基础180
6.1 安装IPFS180
6.1.1 通过安装包安装180
6.1.2 通过Docker安装183
6.1.3 通过ipfs-update安装184
6.2 IPFS仓库配置初始化185
6.2.1 初始化185
6.2.2 访问配置文件186
6.3 与IPFS文件系统进行交互190
6.4 加入IPFS网络环境193
6.5 与HTTP Web交互195
6.6 API使用 196
6.6.1 IPFS命令行用法197
6.6.2 IPFS协议实现扩展200
6.6.3 IPFS端API200
6.7 本章小结202
第7章 IPFS开发进阶203
7.1 在IPFS中发布动态内容203
7.2 持久保存IPFS网络数据206
7.3 操作IPFS Merkle DAG208
7.3.1 创建Merkle DAG结构208
7.3.2 组装子块数据209
7.3.3 块与对象的区别210
7.3.4 操作Block210
7.3.5 操作Object211
7.4 IPFS Pubsub功能的使用212
7.5 私有IPFS网络的搭建与使用215
7.5.1 环境准备216
7.5.2 共享密钥216
7.5.3 上传密钥至节点217
7.5.4 添加启动节点217
7.5.5 启动并查看各个节点217
7.6 本章小结219
第8章 IPFS项目实战220
8.1 利用go-ipfs优化Git分布式服务220
8.1.1 依赖安装221
8.1.2 初始化Git仓库222
8.1.3 IPFS网络挂载223
8.1.4 用Git从IPFS网络克隆仓库225
8.2 基于js-ipfs搭建一个流媒体播放系统227
8.2.1 构建Node.js开发环境227
8.2.2 使用Webpack构建项目229
8.2.3 开发播放器模块231
8.2.4 开发状态栏模块233
8.2.5 引入js-ipfs模块235
8.2.6 实现拖拽上传237
8.2.7 从IPFS中读取流媒体至播放器238
8.2.8 处理流媒体播放状态240
8.2.9 开发总结241
8.3 本章小结242

教学资源推荐
作者: [美] 凯·霍斯特曼(Cay Horstmann) 著
作者: [美]基普·R. 欧文(Kip R. Irvine) 著
作者: 贾伯琪 顾为兵 苏仕华 张四海 何克东 编著
作者: [美]加里·R. 赖特(Gary R. Wright),W. 理查德·史蒂文斯(W. Richard Stevens) 著
参考读物推荐
作者: 张文亮 编著
作者: (美)Aaron Hillegass,Adam Preble 著
作者: Donald Thompson;Rob S. Miles