From 136ac5e0e55ffb45120e973a0a2ee711efc69283 Mon Sep 17 00:00:00 2001 From: Quinten Van Opstal Date: Thu, 27 Jun 2024 13:08:59 +0200 Subject: [PATCH] Look at the pk's in a different way --- .../java/nl/tudelft/trustchain/currencyii/CoinCommunity.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/currencyii/src/main/java/nl/tudelft/trustchain/currencyii/CoinCommunity.kt b/currencyii/src/main/java/nl/tudelft/trustchain/currencyii/CoinCommunity.kt index 57a928988..dd67ac505 100644 --- a/currencyii/src/main/java/nl/tudelft/trustchain/currencyii/CoinCommunity.kt +++ b/currencyii/src/main/java/nl/tudelft/trustchain/currencyii/CoinCommunity.kt @@ -396,7 +396,7 @@ open class CoinCommunity constructor( ?: throw IllegalStateException("Most recent DAO block not found") val peerPK: ArrayList = ArrayList() val blockData = SWJoinBlockTransactionData(mostRecentWalletBlock.transaction).getData() - for (swParticipantPk in blockData.SW_TRUSTCHAIN_PKS) { + for (swParticipantPk in blockData.SW_BITCOIN_PKS) { peerPK.add(swParticipantPk) } return peerPK @@ -417,8 +417,9 @@ open class CoinCommunity constructor( getCurrentLeader()[payload.DAOid.decodeToString()] = null val higherPeers = ArrayList() + for (p in this.getPeers()) { - if (peerPK.contains(p.publicKey.keyToBin().decodeToString()) && p.address.hashCode() > this.myPeer.address.hashCode()) { + if (peerPK.contains(p.publicKey.keyToBin().toHex()) && p.address.hashCode() > this.myPeer.address.hashCode()) { higherPeers.add(p) } } @@ -480,7 +481,7 @@ open class CoinCommunity constructor( val peerPK = getPeersPKInDao(publicKeyBlock) for (peer in peers) { if (peer.publicKey == this.myPeer.publicKey) continue - if (peerPK.contains(peer.publicKey.keyToBin().decodeToString())) { + if (peerPK.contains(peer.publicKey.keyToBin().toHex())) { sendPayload(peer, this.createElectionRequest(publicKeyBlock)) Log.d("LEADER", "Sending to peer at " + peer.address + " in " + serviceId + "...") }