Skip to content

Commit

Permalink
ETCM-207: Flip parameter order in XorOrdering.
Browse files Browse the repository at this point in the history
  • Loading branch information
aakoshh committed Oct 19, 2020
1 parent ad80554 commit 3442908
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Expand Up @@ -30,7 +30,7 @@ class DiscoveryKademliaIntegrationSpec extends KademliaIntegrationSpec("Discover
}

override def makeXorOrdering(baseId: BitVector): Ordering[Node] =
XorOrdering[Node](baseId)(_.id)
XorOrdering[Node](_.id)(baseId)

override def startNode(
selfRecord: PeerRecord,
Expand Down
Expand Up @@ -630,7 +630,7 @@ object DiscoveryService {
*/
protected[v4] def lookup(target: NodeId): Task[SortedSet[Node]] = {
implicit val nodeOrdering: Ordering[Node] =
XorOrdering[Node](target)(_.id)
XorOrdering[Node](_.id)(target)

// Find the 16 closest nodes we know of.
// We'll contact 'alpha' at a time but eventually try all of them
Expand Down
Expand Up @@ -28,7 +28,7 @@ object XorOrdering {
// distance, but in pathological tests it's not intuitive that sets of
// different nodes with the same ID but different attributes disappear
// from the set.
def apply[T](base: BitVector)(f: T => BitVector): Ordering[T] = {
def apply[T](f: T => BitVector)(base: BitVector): Ordering[T] = {
val xorOrdering = new XorOrdering(base)
val tupleOrdering = Ordering.Tuple2(xorOrdering, Ordering.Int)
Ordering.by[T, (BitVector, Int)] { x =>
Expand All @@ -39,7 +39,7 @@ object XorOrdering {

object XorNodeOrdering {
def apply[A](base: BitVector): Ordering[NodeRecord[A]] =
XorOrdering[NodeRecord[A]](base)(_.id)
XorOrdering[NodeRecord[A]](_.id)(base)
}

class XorNodeOrder[A](val base: BitVector) extends Order[NodeRecord[A]] {
Expand Down

0 comments on commit 3442908

Please sign in to comment.