ipfs / go-bitswap

The golang implementation of the bitswap protocol
MIT License
216 stars 112 forks source link

Adding configuration to allow BitSwap receiving not wanted blocks #104

Closed Wondertan closed 5 years ago

Wondertan commented 5 years ago

The issue is that I want to use BitSwap not only to handle blocks it wants, but also any other sent block. Currently BitSwap checks every received block through WantManager's IsWanted() method and just skips it, if false.

In my opinion, this feature may add some flexibility to BitSwap and it could be done by adding global variable like var AllowNotWanted = false or even optioning through options pattern. I need this feature as soon as possible and there is no other way, like implementation substitution, to change behaviour except original code modification. I would be glad to contribute, but first you need to make a decision regarding to the necessity of the change.

Thank you for attention.

hannahhoward commented 5 years ago

@Wondertan

Not accepting blocks that are not wanted is a security decision -- one of our promises to IPFS users is we won't store arbitrary potentially malicious data on their hard drive.

That said, I guess I might be open to this as it's not a default option? But also I'd be curious to hear more about your use case that is motivates this desire.

Wondertan commented 5 years ago

Thank you for response @hannahhoward.

I think you guys are right with the promise, but maybe the decision about storing only wanted blocks is a bit restrained. Logic could be expanded with dependency on the block's content, like having new IPLD type which anyone can receive and parse. I know that dag is an upper abstraction, but custom decision logic could work through passing functions. From my understanding, anyone can add a plugin to IPFS with IPLD parser and appending the plugin would work as an agreement on receiving not wanted blocks, if it truly matters. The case is just an example of how custom decision could add flexibility to IPFS.

My use case is a bit different and simpler. I just want to move decisioning to custom BlockStore.

hannahhoward commented 5 years ago

@Wondertan that's a interesting point-- sorry for the slow response on this.

The good news is the use case you're describing sounds almost exactly like IPLD Selectors and Graphsync, the new IPLD replication protocol we're working on. There's actually a repo of all the code written if your curious: https://github.com/ipfs/go-graphsync (working on this is part of why I haven't been as responsive as I could be on Bitswap)

So.... I dunno if "wait" is a good response, but I think this might satisfy your use case without changing the fundamental nature of bitswap, which is a protocol for requesting and exchanging blocks.

hannahhoward commented 5 years ago

closing unless @Stebalien feels differently with referral to Graphsync as the ultimate solution here.

Wondertan commented 5 years ago

Ok, thanks for response.

I've already discovered graphsync. It relies on ipld-prime, does it already in usable state?