ethersphere / swarm

Swarm: Censorship resistant storage and communication infrastructure for a truly sovereign digital society
https://swarm.ethereum.org/
GNU Lesser General Public License v3.0
489 stars 112 forks source link

check both local pinning and global pinning flags #2186

Open mortelli opened 4 years ago

mortelli commented 4 years ago

In the current global pinning implementation, a user can set both the GlobalPinner and EnablePinning flags separate and independently.

This won't cause the code to break, but it doesn't really make sense to set the GlobalPinner flag if EnablePinning is unset. This is because only locally pinned files should be able to be re-uploaded for repair.

Eventually, when the recovery mechanism is triggered, a global pinner will just fail to re-upload a file if its not pinned. This is part of the logic in the setReUpload function of the localstore package.

If the flags are checked against each other, we can avoid triggering some of these useless recovery processes.

Note, however, that we cannot avoid all of them: a node can have both flags set and still receive recovery requests for a file it does no longer pin, or never pinned in the first place.