Mutable Value Chains
joearms.github.io
joearms.github.io
No but seriously: "SHA which I have chosen in this article has 160 bits, so after more than 2^160 entries have been put into the DHT collisions will occur"
Collisions are largely related to the content that you are hashing. If you are hashing sequential 160 bit chunks of data then Joe's math is theoretically correct. If you are hashing DVD ISO images then you can use math to predict why you should never use sha1.
If you needed to cram it into 160 bits for some hardware reason then you could implement some form of write failure recovery to redistribute writes over them remaining available key space but this would get slower and slower the less and less space you have unless you implement some kind of free space map.
Why?
> The solution is blindingly simple (once you see it) - we represent the sequence as a set Key-Value pairs where the Keys are taken from an iterated sequence of SHA1 checksums. The first key is a random number, thereafter Key[i] = sha(Key[i-1]).
Why not simply use Key[0] = 0, and Key[i] = Key[i-1]+1, or, in other words Key[i] = i?
How? All the keys need to be calculated sequentially which, depending on the application, can take a significant amount of time. Worse this time grows linearly with the number of cores, so massively parallel calculations with several hundreds, thousands, of cores will become increasingly inefficient.