filecoin技术架构分析之十二:filecoin源码分析之内部接口层plumbing&porcelain接口
2019-03-07 18:37
791 查看
本文作者:先河系统杨尉;原创作品,转载请注明出处
上一篇:filecoin技术架构分析之十一:filecoin源码分析之内部接口层api包分析)
下一篇:filecoin技术架构分析之十三:filecoin源码分析之服务层actor及vm
目录
- 12.filecoin源码分析之内部接口层plumbing&porcelain接口 12.1 说明
- 12.2 plumbing&porcelain模式简述
- 12.3 plumbing底层接口
- 12.4 porcelain高层接口
12.1 说明
-
目前官方正在将api包解耦,往plumbing、porcelain中迁移
缘由: 原来的api包,依赖于node包,而node包应该属于api之上的,这导致代码耦合性大 - node作为一个上帝对象,被api包依赖,对架构扩展性,其他类型节点扩展开发不利
- 就在笔者写这篇文章的同时,官方应该还在继续迁移,后面api包会逐步都迁移完
porcelain主要依赖于plumbing接口
上一章所述的api包将会被废除
本文分析版本,go-filecoin版本:master 2c87fd59 (2019.3.7)
12.2 plumbing&porcelain模式简述
- 该模式是借鉴git的思路,提供两种接口,porcelain偏高层面对用户更加友好方便;plumbing偏底层,友好度弱于porcelain
- porcelain是英文瓷器的意思,类似洗手盆之类;plumbing是水管装置的意思,类似下水管,用户当然直接用洗手盆省心,不用管水管的事情
- 用户级更偏向用porcelain,协议级更偏向使用plumbing,
12.3 plumbing底层接口
-
说明
plumbing底层接口是为实现协议以及面向网络的必须最小实现 - 更应用级别的调用更多将会调用到porcelain高层接口
提供的具体功能接口
-
区块状态读取
具体的方法如下
▼ package plumbing ▶ imports ▼+API : struct [fields] -chain : chain.ReadStore -config : *cfg.Config -logger : logging.EventLogger -msgPool : *core.MessagePool -msgPreviewer : *msg.Previewer -msgQueryer : *msg.Queryer -msgSender : *msg.Sender -msgWaiter : *msg.Waiter -network : *ntwk.Network -sigGetter : *mthdsig.Getter -wallet : *wallet.Wallet [methods] +ActorGet(ctx context.Context, addr address.Address) : *actor.Actor, error +ActorGetSignature(ctx context.Context, actorAddr address.Address, method string) : *exec.FunctionSignature, error +BlockGet(ctx context.Context, id cid.Cid) : *types.Block, error +ChainHead(ctx context.Context) : types.TipSet +ChainLs(ctx context.Context) : chan interface{} +ConfigGet(dottedPath string) : interface{}, error +ConfigSet(dottedPath string, paramJSON string) : error +MessagePoolGet(cid cid.Cid) : *types.SignedMessage, bool +MessagePoolPending() : []*types.SignedMessage +MessagePoolRemove(cid cid.Cid) +MessagePreview(ctx context.Context, from, to address.Address, method string, params ...interface{}) : types.GasUnits, error +MessageQuery(ctx context.Context, optFrom, to address.Address, method string, params ...interface{}) : [][]byte, *exec.FunctionSignature, error +MessageSend(ctx context.Context, from, to address.Address, value *types.AttoFIL, gasPrice types.AttoFIL, gasLimit types.GasUnits, method string, params ...interface{}) : cid.Cid, error +MessageWait(ctx context.Context, msgCid cid.Cid, cb func(*types.Block, *types.SignedMessage, *types.MessageReceipt) error) : error +NetworkFindProvidersAsync(ctx context.Context, key cid.Cid, count int) : chan pstore.PeerInfo +NetworkGetPeerID() : peer.ID +PubSubPublish(topic string, data []byte) : error +PubSubSubscribe(topic string) : pubsub.Subscription, error +SignBytes(data []byte, addr address.Address) : types.Signature, error +WalletAddresses() : []address.Address +WalletFind(address address.Address) : wallet.Backend, error +WalletNewAddress() : address.Address, error [functions] +New(deps *APIDeps) : *API
12.4 porcelain高层接口
-
说明
porcelain主要依赖plumbing实现。 - 主要是面向用户级操作
提供功能
-
获取区块高度
▼ package porcelain ▶ imports ▼+API : struct [embedded] +*plumbing.API : *plumbing.API [methods] +ChainBlockHeight(ctx context.Context) : *types.BlockHeight, error +CreatePayments(ctx context.Context, config CreatePaymentsParams) : *CreatePaymentsReturn, error +GetAndMaybeSetDefaultSenderAddress() : address.Address, error +MessagePoolWait(ctx context.Context, messageCount uint) : []*types.SignedMessage, error +MessageSendWithDefaultAddress(ctx context.Context, from, to address.Address, value *types.AttoFIL, gasPrice types.AttoFIL, gasLimit types.GasUnits, method string, params ...interface{}) : cid.Cid, error +MinerGetAsk(ctx context.Context, minerAddr address.Address, askID uint64) : minerActor.Ask, error +MinerGetOwnerAddress(ctx context.Context, minerAddr address.Address) : address.Address, error +MinerGetPeerID(ctx context.Context, minerAddr address.Address) : peer.ID, error +MinerPreviewCreate(ctx context.Context, fromAddr address.Address, pledge uint64, pid peer.ID, collateral *types.AttoFIL) : types.GasUnits, error +MinerPreviewSetPrice(ctx context.Context, from address.Address, miner address.Address, price *types.AttoFIL, expiry *big.Int) : types.GasUnits, error +MinerSetPrice(ctx context.Context, from address.Address, miner address.Address, gasPrice types.AttoFIL, gasLimit types.GasUnits, price *types.AttoFIL, expiry *big.Int) : MinerSetPriceResponse, error +PaymentChannelLs(ctx context.Context, fromAddr address.Address, payerAddr address.Address) : map[string]*paymentbroker.PaymentChannel, error +PaymentChannelVoucher(ctx context.Context, fromAddr address.Address, channel *types.ChannelID, amount *types.AttoFIL, validAt *types.BlockHeight) : *paymentbroker.PaymentVoucher, error +WalletBalance(ctx context.Context, address address.Address) : *types.AttoFIL, error [functions] +New(plumbing *plumbing.API) : *API
上一篇:filecoin技术架构分析之十一:filecoin源码分析之内部接口层api包分析)
下一篇:filecoin技术架构分析之十三:filecoin源码分析之服务层actor及vm
相关文章推荐
- filecoin技术架构分析之四:filecoin源码顶层架构分析
- filecoin技术架构分析之十三:filecoin源码分析之服务层actor及vm
- filecoin技术架构分析之十五:filecoin源码分析之节点运行逻辑
- filecoin技术架构分析之十四:filecoin源码分析之服务层链同步、共识协议及挖矿
- 【Java安全技术探索之路系列:Java可扩展安全架构】之十二:JSSE(二):JSSE类和接口
- Jquery 源码分析一: 整体架构、链式调用、插件接口
- Shiro技术架构之源码分析
- JavaSE学习随笔(一) Cloneable接口源码分析与技术细节
- 技术积累BCM-SDK架构分析及源码移植-nios2平台移植
- Volley的源码分析(架构层次分析)
- Backbone源码分析-Backbone架构+流程图
- OpenStack_Swift源码分析——Ring代码的组织架构
- 大型网站架构设计及技术分析(一)
- Hadoop源码分析之DistributedFileSystem
- 淘宝应对"双11"的技术架构分析
- java源码分析--Enumeration接口和Iterator接口
- MetaQ技术内幕——源码分析 (地址)
- 求 架构设计 的视屏和 设计模式的视频 性能优化 的视频 系统源码分析 的视频 android
- Java-Collection源码分析(十二)——SortedMap和NavigableMap
- Android Camera 系统架构源码分析(2)---->Camera的startPreview和setPreviewCallback