Skip to content

Commit

Permalink
add log statements needed to benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
AirWinter committed Mar 26, 2024
1 parent 5319610 commit c123d9e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ class FOCCommunity(
}

override fun sendPullVotesMessage() {
Log.i("pull-based", "Sending pull request")
Log.i("benchmarking", "Sending pull request")
for (peer in getPeers()) {
Log.i("pull-based", "sending pull vote request to ${peer.mid}")
Log.i("benchmarking", "sending pull vote request to ${peer.mid}")
val packet =
serializePacket(MessageId.FOC_THALIS_MESSAGE, FOCMessage(pullRequestString), true)
send(peer.address, packet)
Expand Down Expand Up @@ -181,7 +181,7 @@ class FOCCommunity(
Log.i("personal", peer.mid + ": " + payload.message)

if (payload.message.contains(pullRequestString)) {
Log.i("pull-based", "Sending all my votes to ${peer.address}")
Log.i("benchmarking", "Sending all my votes to ${peer.address}")
val m =
serializePacket(
MessageId.PULL_VOTE_MESSAGE,
Expand Down Expand Up @@ -229,19 +229,20 @@ class FOCCommunity(
}

private fun onPullVoteMessage(packet: Packet) {
Log.i("pull-based", "onPullVoteMessage called")
Log.i("benchmarking", "onPullVoteMessage called")
val (peer, payload) =
packet.getDecryptedAuthPayload(
FOCPullVoteMessage.Deserializer,
myPeer.key as PrivateKey
)
Log.i("pull-based", "Received votemap from ${peer.address}")
Log.i("benchmarking", "Received votemap from ${peer.address}")
focVoteTracker.mergeVoteMaps(payload.voteMap)
activity?.runOnUiThread {
for (key in focVoteTracker.getCurrentState().keys) {
activity?.updateVoteCounts(key)
}
}
Log.i("benchmarking", "Updated vote maps")
}

private fun onAppRequestPacket(packet: Packet) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package nl.tudelft.trustchain.foc.community

import android.util.Log
import nl.tudelft.ipv8.messaging.Deserializable

data class FOCMessage(val message: String) : nl.tudelft.ipv8.messaging.Serializable {
Expand All @@ -13,6 +14,7 @@ data class FOCMessage(val message: String) : nl.tudelft.ipv8.messaging.Serializa
offset: Int
): Pair<FOCMessage, Int> {
var toReturn = buffer.toString(Charsets.UTF_8)
Log.i("benchmarking", "Deserialize FOCMessage: ${buffer.size} Bytes")
return Pair(FOCMessage(toReturn), buffer.size)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ data class FOCPullVoteMessage(val voteMap: HashMap<String, HashSet<FOCSignedVote
val (payload, localOffset) = deserializeVarLen(buffer, offset)
val set = FOCPullVoteMessage(SerializationUtils.deserialize(payload))

Log.i("pull-based", "${localOffset - offset} Bytes")
Log.i("benchmarking", "Deserialize FOCPullVoteMessage: ${localOffset - offset} Bytes")
return Pair(set, offset)
}
}
Expand Down

0 comments on commit c123d9e

Please sign in to comment.