swarm/pot: pot.remove fixed (#18431)

* swarm/pot: refactored pot.remove(), updated comments

* swarm/pot: comments updated
This commit is contained in:
gluk256
2019-01-11 23:42:33 +04:00
committed by Viktor Trón
parent 88168ff5c5
commit 1636d9574b
3 changed files with 87 additions and 21 deletions

View File

@@ -162,7 +162,6 @@ func ToBytes(v Val) []byte {
}
// DefaultPof returns a proximity order comparison operator function
// where all
func DefaultPof(max int) func(one, other Val, pos int) (int, bool) {
return func(one, other Val, pos int) (int, bool) {
po, eq := proximityOrder(ToBytes(one), ToBytes(other), pos)
@@ -174,6 +173,9 @@ func DefaultPof(max int) func(one, other Val, pos int) (int, bool) {
}
}
// proximityOrder returns two parameters:
// 1. relative proximity order of the arguments one & other;
// 2. boolean indicating whether the full match occurred (one == other).
func proximityOrder(one, other []byte, pos int) (int, bool) {
for i := pos / 8; i < len(one); i++ {
if one[i] == other[i] {