Skip to content

Commit

Permalink
clean up the logging
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Dec 3, 2024
1 parent bc7d774 commit 2a3d30b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 34 deletions.
29 changes: 0 additions & 29 deletions library/src/main/java/org/xmtp/android/library/Client.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.xmtp.android.library

import android.content.Context
import android.util.Log
import kotlinx.coroutines.runBlocking
import org.xmtp.android.library.codecs.ContentCodec
import org.xmtp.android.library.codecs.TextCodec
Expand All @@ -18,7 +17,6 @@ import uniffi.xmtpv3.getInboxIdForAddress
import uniffi.xmtpv3.getVersionInfo
import uniffi.xmtpv3.org.xmtp.android.library.libxmtp.InboxState
import java.io.File
import java.util.Date

typealias PreEventCallback = suspend () -> Unit

Expand Down Expand Up @@ -63,15 +61,12 @@ class Client() {
}

suspend fun getOrCreateInboxId(environment: ClientOptions.Api, address: String): String {
val start = Date()
var inboxId = getInboxIdForAddress(
logger = XMTPLogger(),
host = environment.env.getUrl(),
isSecure = environment.isSecure,
accountAddress = address.lowercase()
)
val end = Date()
Log.d("PERF", "Get inboxId in ${(end.time - start.time) / 1000.0}s")
if (inboxId.isNullOrBlank()) {
inboxId = generateInboxId(address.lowercase(), 0.toULong())
}
Expand Down Expand Up @@ -109,21 +104,15 @@ class Client() {
inboxId: String? = null
): Client {
val accountAddress = address.lowercase()
val start2 = Date()
val recoveredInboxId = inboxId ?: getOrCreateInboxId(clientOptions.api, accountAddress)
val end2 = Date()
Log.d("PERF", "Get or create inboxId in ${(end2.time - start2.time) / 1000.0}s")

val start = Date()
val (ffiClient, dbPath) = createFfiClient(
accountAddress,
recoveredInboxId,
clientOptions,
signingKey,
clientOptions.appContext,
)
val end = Date()
Log.d("PERF", "Create ffiClient with sigs ${(end.time - start.time) / 1000.0}s")

return Client(
accountAddress,
Expand Down Expand Up @@ -169,7 +158,6 @@ class Client() {
): Pair<FfiXmtpClient, String> {
val alias = "xmtp-${options.api.env}-$inboxId"

val start1 = Date()
val mlsDbDirectory = options.dbDirectory
val directoryFile = if (mlsDbDirectory != null) {
File(mlsDbDirectory)
Expand All @@ -178,10 +166,7 @@ class Client() {
}
directoryFile.mkdir()
dbPath = directoryFile.absolutePath + "/$alias.db3"
val end1 = Date()
Log.d("PERF", "Create database ${(end1.time - start1.time) / 1000.0}s")

val start = Date()
val ffiClient = createClient(
logger = logger,
host = options.api.env.getUrl(),
Expand All @@ -194,25 +179,17 @@ class Client() {
legacySignedPrivateKeyProto = null,
historySyncUrl = options.historySyncUrl
)
val end = Date()
Log.d("PERF", "Create ffi client in ${(end.time - start.time) / 1000.0}s")

options.preAuthenticateToInboxCallback?.let {
runBlocking {
it.invoke()
}
}
val start2 = Date()
ffiClient.signatureRequest()?.let { signatureRequest ->
signingKey?.let { handleSignature(signatureRequest, it) }
?: throw XMTPException("No signer passed but signer was required.")
val start3 = Date()
ffiClient.registerIdentity(signatureRequest)
val end3 = Date()
Log.d("PERF", "Register identity ${(end3.time - start3.time) / 1000.0}s")
}
val end2 = Date()
Log.d("PERF", "Handle signatures ${(end2.time - start2.time) / 1000.0}s")
return Pair(ffiClient, dbPath)
}

Expand Down Expand Up @@ -249,15 +226,9 @@ class Client() {
signingKey.blockNumber?.toULong()
)
} else {
val start1 = Date()
signingKey.sign(signatureRequest.signatureText())?.let {
val start3 = Date()
signatureRequest.addEcdsaSignature(it.rawData)
val end3 = Date()
Log.d("PERF", "Add signature ${(end3.time - start3.time) / 1000.0}s")
}
val end1 = Date()
Log.d("PERF", "Do signing ${(end1.time - start1.time) / 1000.0}s")
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.xmtp.android.library.messages

import android.util.Log
import com.google.protobuf.kotlin.toByteString
import org.web3j.crypto.ECKeyPair
import org.web3j.crypto.Sign
Expand Down Expand Up @@ -64,7 +63,6 @@ class PrivateKeyBuilder : SigningKey {
}

override suspend fun sign(data: ByteArray): SignatureOuterClass.Signature {
val start = Date()
val signatureData =
Sign.signMessage(
data,
Expand All @@ -79,9 +77,6 @@ class PrivateKeyBuilder : SigningKey {
builder.recovery = signatureKey[64].toInt()
}.build()
}.build()
val end = Date()
val time1 = end.time - start.time
Log.d("PERF", "Did the signature ${time1 / 1000.0}s")

return sign
}
Expand Down

0 comments on commit 2a3d30b

Please sign in to comment.