# SSB Blobs ## Source code * ssb-blobs: https://github.com/ssbc/ssb-blobs/blob/master/inject.js * (our implementation): ssb-cluster: https://github.com/tauChang/ssb-cluster ## How it works 1. node0 adds a blob `B`. To trigger the diffusion, node0 broadcasts `wants(node0, B)` 2. node0's peer, node1, sees that node0 wants `B`. Out of sympathy, node1 acts like it wants `B`, and now it also broadcasts `wants(node1, B)`. 3. node0 sees that node1 wants `B`, and node0 does have `B`, so it respond to node1 it has `B`. 4. node1 sees that node0 has `B`, so it request `B` from node0. 5. Now node1 has `B`. It broadcasts that it has `B`. 6. node0 sees that node1 says it has `B`. And it follows the same step to get the blob `B` from node1. * This explains why there is data transmitted to node0 even though it is the one publishing the blob. ## Does that mean that all nodes will gets `B` from node0? * It is possible that, before node0 serves node2, node1 already got `B` from node0, and node2 see that node1 broadcasts that it has `B`, so it gets `B` from node2. In this example, node1 is the only node that gets blob from node0. All other nodes (except node4) gets blob from node1. * However, I'm not sure why node4 did not get `B` from node0 but instead got it from node3. * Example 1: ![](https://hackmd.io/_uploads/Hy03zSdVn.png) * Example 2: ![](https://hackmd.io/_uploads/HJsYrSdN2.png)