ipfs, bitswap provider vs. go-ipfs-provider

Provider

Provider system is responsible for announcing and reannouncing to network that a node has content.

Provider is done through Content Routing, aka DHT, AddProvider procedure.

Bitswap provider

bs.newBlocks is channel listening for any newBlock anoucement:

Two cases:

  • Originator: or Creator, ‘I’ make this block.
    – bitswap.HasBlock
  • Receiver: I got a block through bitswap, and have to annouce to the network that I have it now
    – bitswap.ReceiveMessage

Anyway, block CID will be sent to a channel named bitswap.newBlocks for further processing asynchronously, by a worker named provideCollector()…

Call stack of HasBlock():

github.com/ipfs/go-bitswap.(*Bitswap).receiveBlocksFrom at bitswap.go:351
github.com/ipfs/go-bitswap.(*Bitswap).HasBlock at bitswap.go:278
github.com/ipfs/go-blockservice.(*blockService).AddBlock at blockservice.go:153
github.com/ipfs/go-merkledag.(*dagService).Add at merkledag.go:51
<autogenerated>:2
github.com/ipfs/go-mfs.(*Directory).GetNode at dir.go:444
github.com/ipfs/go-mfs.(*Directory).Flush at dir.go:340
github.com/ipfs/go-ipfs/core/coreunix.(*Adder).AddAllAndPin at add.go:280
github.com/ipfs/go-ipfs/core/coreapi.(*UnixfsAPI).Add at unixfs.go:167
github.com/ipfs/go-ipfs/core/commands.glob..func6.1 at add.go:237
runtime.goexit at asm_amd64.s:1357
 - Async stack trace
github.com/ipfs/go-ipfs/core/commands.glob..func6 at add.go:234

go-ipfs-provider

go-ipfs-provider is a independent system with bitswap. It is created by FX injection when ipfs constructing the IpfsNode.

The provider will start a looping worker to handleAnnouncements() which will dequeue CID from a channel and then call DHT.AddProvider

An Interface named System will expose the Provide method outside.

Provide method will be invoked when ipfs trys adding content:

PIN.Add & UnixFs.Add

Conclusion

So, it is clear that two systems are totally irrelvent at this moment.

In README of bitswap, it is said:

As a bitswap client receives blocks, by default it announces them on
the provided content routing system (again, a DHT in most cases). This
behaviour can be disabled by passing bitswap.ProvideEnabled(false) as
a parameter when initializing Bitswap. IPFS currently has its own
experimental provider system (go-ipfs-provider) which will eventually
replace Bitswap’s system entirely.

Let’s wait and see.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值