forked from Tribler/trustchain-superapp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86c0171
commit 3736c18
Showing
22 changed files
with
301 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...rc/main/java/nl/tudelft/trustchain/offlineeuro/community/message/AddressRequestMessage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package nl.tudelft.trustchain.offlineeuro.community.message | ||
|
||
import nl.tudelft.ipv8.Peer | ||
|
||
class AddressRequestMessage( | ||
val requestingPeer: Peer | ||
): ICommunityMessage { | ||
override val messageType = CommunityMessageType.AddressRequestMessage | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...eeuro/src/main/java/nl/tudelft/trustchain/offlineeuro/community/payload/AddressPayload.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package nl.tudelft.trustchain.offlineeuro.community.payload | ||
|
||
import nl.tudelft.ipv8.messaging.Deserializable | ||
import nl.tudelft.ipv8.messaging.SERIALIZED_LONG_SIZE | ||
import nl.tudelft.ipv8.messaging.Serializable | ||
import nl.tudelft.ipv8.messaging.deserializeLong | ||
import nl.tudelft.ipv8.messaging.deserializeVarLen | ||
import nl.tudelft.ipv8.messaging.serializeLong | ||
import nl.tudelft.ipv8.messaging.serializeVarLen | ||
import nl.tudelft.trustchain.offlineeuro.enums.Role | ||
|
||
class AddressPayload( | ||
val userName: String, | ||
val publicKey: ByteArray, | ||
val role: Role | ||
) : Serializable { | ||
override fun serialize(): ByteArray { | ||
var payload = ByteArray(0) | ||
payload += serializeVarLen(userName.toByteArray()) | ||
payload += serializeVarLen(publicKey) | ||
payload += serializeLong(role.ordinal.toLong()) | ||
return payload | ||
} | ||
|
||
companion object Deserializer : Deserializable<AddressPayload> { | ||
override fun deserialize( | ||
buffer: ByteArray, | ||
offset: Int | ||
): Pair<AddressPayload, Int> { | ||
var localOffset = offset | ||
|
||
val (nameBytes, nameSize) = deserializeVarLen(buffer, localOffset) | ||
localOffset += nameSize | ||
val (publicKeyBytes, publicKeyBytesSize) = deserializeVarLen(buffer, localOffset) | ||
localOffset += publicKeyBytesSize | ||
|
||
val role = deserializeLong(buffer, localOffset) | ||
localOffset += SERIALIZED_LONG_SIZE | ||
|
||
return Pair( | ||
AddressPayload( | ||
nameBytes.toString(Charsets.UTF_8), | ||
publicKeyBytes, | ||
Role.fromLong(role) | ||
), | ||
localOffset - offset | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.