Skip to content

Commit

Permalink
refactor: rename non-stabilizing-gossip function
Browse files Browse the repository at this point in the history
  • Loading branch information
angelacorte committed Nov 15, 2024
1 parent 5598e4f commit 8a5c10b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ object NonSelfStabilizingGossip {
* A non-self-stabilizing function for repeated propagation of a [value] and [aggregation]
* of state estimates between neighboring devices.
*/
fun <ID : Any, Value> Aggregate<ID>.nonSelfStabilizingGossip(
fun <ID : Any, Value> Aggregate<ID>.gossip(
value: Value,
aggregation: (Value, Value) -> Value,
): Value = share(value) {
Expand All @@ -110,8 +110,5 @@ object NonSelfStabilizingGossip {
*/
fun <ID : Any> Aggregate<ID>.everHappened(
condition: () -> Boolean,
default: Boolean = false,
): Boolean = share(default) {
condition() || it.fold(default) { a, b -> a || b }
}
): Boolean = gossip(condition()) { a, b -> a || b }
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package it.unibo.collektive.stdlib.test

import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.shouldBe
import it.unibo.collektive.stdlib.NonSelfStabilizingGossip.nonSelfStabilizingGossip
import it.unibo.collektive.stdlib.NonSelfStabilizingGossip.gossip
import it.unibo.collektive.stdlib.SelfStabilizingGossip.gossipMax
import it.unibo.collektive.stdlib.SelfStabilizingGossip.gossipMin
import it.unibo.collektive.testing.Environment
Expand Down Expand Up @@ -59,7 +59,7 @@ class GossipTest : StringSpec({

fun squareMooreGridWithNonSelfStabilizingGossip(size: Int) =
mooreGrid<Int>(size, size, { _, _ -> Int.MAX_VALUE }) {
nonSelfStabilizingGossip(localId) { first, second -> if (first >= second) first else second }
gossip(localId) { first, second -> if (first >= second) first else second }
}.apply {
nodes.size shouldBe size * size
val initial = status().values.distinct()
Expand Down

0 comments on commit 8a5c10b

Please sign in to comment.