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.