swarm/storage: move/add Proximity GoDoc from deleted private function

The mentioned proximity() private function was deleted in:
1ca8fc1e6f
This commit is contained in:
Ferenc Szabo 2018-10-27 13:53:40 +02:00
parent 1ca8fc1e6f
commit 91c5467025

View file

@ -80,6 +80,19 @@ func (a Address) bits(i, j uint) uint {
return res return res
} }
// Proximity(x, y) returns the proximity order of the MSB distance between x and y
//
// The distance metric MSB(x, y) of two equal length byte sequences x an y is the
// value of the binary integer cast of the x^y, ie., x and y bitwise xor-ed.
// the binary cast is big endian: most significant bit first (=MSB).
//
// Proximity(x, y) is a discrete logarithmic scaling of the MSB distance.
// It is defined as the reverse rank of the integer part of the base 2
// logarithm of the distance.
// It is calculated by counting the number of common leading zeros in the (MSB)
// binary representation of the x^y.
//
// (0 farthest, 255 closest, 256 self)
func Proximity(one, other []byte) (ret int) { func Proximity(one, other []byte) (ret int) {
b := (MaxPO-1)/8 + 1 b := (MaxPO-1)/8 + 1
if b > len(one) { if b > len(one) {