jbenet/go-ipfs — pull request #388 by maybebtc (2014-11-27 02:24:06+00:00)
Title: refactor(bitswap, blockservice) Give bitswap responsibility for local datastore Gets/Puts

1.
> Despite these facts, bitswap has been saddled with an awkward responsibility of adding blocks received from the network to the datastore. We're making an assumption that callers want this behavior, but is it really true? Blockservice is responsible for mediating client requests. It optimizes performance by consulting the datastore before consulting bitswap. blockservice should add received blocks to the datastore. - @maybebtc

2.
> Dividing the responsibility is awkward. do note though that bitswap in the future may retrieve + store blocks for the sake of trading. (blocks not requested by the client). So it will need write access to a datastore/blockstore. Maybe the correct thing to do is sink the full responsibilities into bitswap ("consult the datastore before making network requests," and "write to the datastore when the local client calls HasBlock"). - @jbenet

3.
Here's a PR that gives bitswap more responsibility.

@whyrusleeping @jbenet

We may want to wait until after #386 is merged. All's the same to me though.