diff --git a/sdk/src/androidTest/java/network/xyo/client/XyoPanelTest.kt b/sdk/src/androidTest/java/network/xyo/client/XyoPanelTest.kt index 8e98967..c03445f 100644 --- a/sdk/src/androidTest/java/network/xyo/client/XyoPanelTest.kt +++ b/sdk/src/androidTest/java/network/xyo/client/XyoPanelTest.kt @@ -65,7 +65,7 @@ class XyoPanelTest { runBlocking { val witnessAccount = Account.fromPrivateKey("9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08") val witness2Account = Account.fromPrivateKey("5a95531488b4d0d3645aea49678297ae9e2034879ce0389b80eb788e8b533592") - val witness = XyoWitness(witnessAccount, fun(_: Context, _: String?): List { + val witness = XyoWitness(witnessAccount, fun(_: Context): List { return listOf(BasicPayload()) }) val panel = XyoPanel(appContext, Account.random(), arrayListOf(Pair(nodeUrl, Account.random())), listOf(witness, XyoSystemInfoWitness(witness2Account), XyoLocationWitness())) @@ -94,7 +94,7 @@ class XyoPanelTest { @Test fun testSimplePanelReport() { runBlocking { - val panel = XyoPanel(appContext, Account.random(), fun(_:Context, _: String?): List { + val panel = XyoPanel(appContext, Account.random(), fun(_:Context): List { return listOf(XyoEventPayload("test_event")) }) val result = panel.reportAsyncQuery() diff --git a/sdk/src/androidTest/java/network/xyo/client/XyoPayloadTest.kt b/sdk/src/androidTest/java/network/xyo/client/XyoPayloadTest.kt index b203ed5..d97ffa8 100644 --- a/sdk/src/androidTest/java/network/xyo/client/XyoPayloadTest.kt +++ b/sdk/src/androidTest/java/network/xyo/client/XyoPayloadTest.kt @@ -93,7 +93,7 @@ class XyoPayloadTest { @Test fun testRoundTripPanel() { val address = Account.fromPrivateKey("5a95531488b4d0d3645aea49678297ae9e2034879ce0389b80eb788e8b533592") - val witness = XyoWitness(address, fun(_: Context, _: String?): List { + val witness = XyoWitness(address, fun(_: Context): List { return listOf(BasicPayload()) }) diff --git a/sdk/src/main/java/network/xyo/client/XyoPanel.kt b/sdk/src/main/java/network/xyo/client/XyoPanel.kt index 1c9a537..21c3e21 100644 --- a/sdk/src/main/java/network/xyo/client/XyoPanel.kt +++ b/sdk/src/main/java/network/xyo/client/XyoPanel.kt @@ -29,7 +29,6 @@ class XyoPanel( private val witnesses: List>?, private val nodeUrlsAndAccounts: ArrayList>? ) { - var previousHash: String? = null private var nodes: MutableList? = null var defaultAccount: AccountInstance? = null @@ -80,7 +79,7 @@ class XyoPanel( constructor( context: Context, account: AccountInstance, - observe: ((context: Context, previousHash: String?) -> List?)? + observe: ((context: Context) -> List?)? ): this( context, account, @@ -114,7 +113,7 @@ class XyoPanel( suspend fun eventAsync(event: String): XyoPanelReportResult { val adhocWitnessList = listOf( XyoWitness({ - _, previousHash -> listOf(XyoEventPayload(event)) + _, -> listOf(XyoEventPayload(event)) }) ) return this.reportAsync(adhocWitnessList) @@ -124,7 +123,7 @@ class XyoPanel( suspend fun eventAsyncQuery(event: String): XyoPanelReportQueryResult { val adhocWitnessList = listOf( XyoWitness({ - _, previousHash -> listOf(XyoEventPayload(event)) + _, -> listOf(XyoEventPayload(event)) }) ) return reportAsyncQuery(adhocWitnessList) @@ -167,7 +166,6 @@ class XyoPanel( @kotlinx.coroutines.ExperimentalCoroutinesApi suspend fun reportAsync(adhocWitnesses: List> = emptyList()): XyoPanelReportResult { val bw = generateBoundWitnessJson(adhocWitnesses) - previousHash = bw._hash val results = mutableListOf() archivists?.forEach { archivist -> results.add(archivist.postBoundWitnessAsync(bw)) @@ -179,7 +177,6 @@ class XyoPanel( suspend fun reportAsyncQuery(adhocWitnesses: List> = emptyList()): XyoPanelReportQueryResult { if (nodes == null) resolveNodes() val bw = generateBoundWitnessJson() - previousHash = bw._hash val payloads = generatePayloads(adhocWitnesses) val results = mutableListOf() diff --git a/sdk/src/main/java/network/xyo/client/XyoWitness.kt b/sdk/src/main/java/network/xyo/client/XyoWitness.kt index af39317..59050d7 100644 --- a/sdk/src/main/java/network/xyo/client/XyoWitness.kt +++ b/sdk/src/main/java/network/xyo/client/XyoWitness.kt @@ -8,37 +8,34 @@ import network.xyo.client.account.model.AccountInstance import network.xyo.client.payload.XyoPayload abstract class DeferredObserver { - abstract suspend fun deferredDetect(context: Context, previousHash: String?): List? + abstract suspend fun deferredDetect(context: Context): List? } @RequiresApi(Build.VERSION_CODES.M) open class XyoWitness ( val address: AccountInstance = Account.random(), - private val observer: ((context: Context, previousHash: String) -> List?)? = null, - var previousHash: String = "", + private val observer: ((context: Context) -> List?)? = null, val deferredObserver: DeferredObserver? = null ) { constructor( - observer: ((context: Context, previousHash: String) -> List?)?, - previousHash: String = "", + observer: ((context: Context) -> List?)?, account: AccountInstance = Account.random() - ): this(account, observer, previousHash, null) + ): this(account, observer) constructor( observer: DeferredObserver?, - previousHash: String = "", account: AccountInstance = Account.random() - ): this(account, null, previousHash, observer) + ): this(account, null, observer) open suspend fun observe(context: Context): List? { val appContext = context.applicationContext if (deferredObserver !== null) { - val payload = deferredObserver.deferredDetect(appContext, previousHash) + val payload = deferredObserver.deferredDetect(appContext) return payload } observer?.let { - val payloads = it(appContext, previousHash) + val payloads = it(appContext) return payloads } return null diff --git a/sdk/src/main/java/network/xyo/client/witness/location/info/XyoLocationWitness.kt b/sdk/src/main/java/network/xyo/client/witness/location/info/XyoLocationWitness.kt index 53d381f..f06f05e 100644 --- a/sdk/src/main/java/network/xyo/client/witness/location/info/XyoLocationWitness.kt +++ b/sdk/src/main/java/network/xyo/client/witness/location/info/XyoLocationWitness.kt @@ -12,7 +12,6 @@ import network.xyo.client.account.model.AccountInstance class DeferredLocationObserver : DeferredObserver() { override suspend fun deferredDetect( context: Context, - previousHash: String? ): List? { try { return listOf(XyoLocationPayload.detect(context)) @@ -26,6 +25,5 @@ class DeferredLocationObserver : DeferredObserver() { @RequiresApi(Build.VERSION_CODES.M) class XyoLocationWitness(address: AccountInstance = Account.random()) : XyoWitness( DeferredLocationObserver(), - "", address - ) \ No newline at end of file +) \ No newline at end of file diff --git a/sdk/src/main/java/network/xyo/client/witness/system/info/XyoSystemInfoWitness.kt b/sdk/src/main/java/network/xyo/client/witness/system/info/XyoSystemInfoWitness.kt index 0a1d762..1193cee 100644 --- a/sdk/src/main/java/network/xyo/client/witness/system/info/XyoSystemInfoWitness.kt +++ b/sdk/src/main/java/network/xyo/client/witness/system/info/XyoSystemInfoWitness.kt @@ -9,9 +9,8 @@ import network.xyo.client.account.model.AccountInstance @RequiresApi(Build.VERSION_CODES.M) class XyoSystemInfoWitness(address: AccountInstance = Account.random()) : XyoWitness( - fun (context: Context, _: String?): List { + fun (context: Context): List { return listOf(XyoSystemInfoPayload.detect(context)) }, - "", address ) \ No newline at end of file