From ddef661e932c65abcb62de5bf56250c01ea2e9f3 Mon Sep 17 00:00:00 2001 From: Bohdan Vanieiev Date: Tue, 17 Nov 2020 14:30:54 +0200 Subject: [PATCH 1/2] 1 --- .../sdk/alt/SecurityInheritingChain.kt | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/altchain-sdk/src/main/kotlin/org/veriblock/sdk/alt/SecurityInheritingChain.kt b/altchain-sdk/src/main/kotlin/org/veriblock/sdk/alt/SecurityInheritingChain.kt index 81a1bda35..e77d4c646 100644 --- a/altchain-sdk/src/main/kotlin/org/veriblock/sdk/alt/SecurityInheritingChain.kt +++ b/altchain-sdk/src/main/kotlin/org/veriblock/sdk/alt/SecurityInheritingChain.kt @@ -23,12 +23,12 @@ interface SecurityInheritingChain { /** * Common configuration for the chain. */ - val config: ChainConfig + suspend fun getConfig(): ChainConfig /** * Returns this security inheriting chain's unique identifier. */ - val id: Long + suspend fun getId(): Long /** * Returns this security inheriting chain's key, usually the token symbol. @@ -71,41 +71,39 @@ interface SecurityInheritingChain { suspend fun getTransaction(txId: String): SecurityInheritingTransaction? /** - * Returns this security inheriting chain's payout delay, in blocks. + * Returns this security inheriting chain's best known VeriBlock Block hash. */ - fun getPayoutDelay(): Int + suspend fun getVbkBestKnownBlockHash(): String - /** - * Returns this security inheriting chain's best known VeriBlock Block hash. + /** + * Returns this security inheriting chain's VBK block */ - suspend fun getBestKnownVbkBlockHash(): String + suspend fun getVbkBlock(hash: String): VbkBlock /** - * Returns this security inheriting chain's PoP mempool (ATVs and VTBs). + * Returns this security inheriting chain's best known Bitcoin Block hash. */ - suspend fun getPopMempool(): PopMempool + suspend fun getBtcBestKnownBlockHash(): String /** - * Retrieves mining instruction from the SI chain for the given [blockHeight] (or the best block height - * if [blockHeight] is null). + * Returns this security inheriting chain's BTC block */ - suspend fun getMiningInstruction(blockHeight: Int? = null): ApmInstruction + suspend fun getBtcBlock(hash: String): BtcBlock /** - * Submits VeriBlock context blocks ([contextBlocks]), ATVs ([atvs]) and VTBs ([vtbs]) to the altchain - * @return The submission's resulting first ATV id + * Returns this security inheriting chain's PoP mempool (ATVs and VTBs). */ - suspend fun submit( - contextBlocks: List, - atvs: List, - vtbs: List - ) - - suspend fun submitContext(contextBlocks: List) = submit(contextBlocks, emptyList(), emptyList()) + suspend fun getPopMempool(): PopMempool - suspend fun submitAtvs(atvs: List) = submit(emptyList(), atvs, emptyList()) + /** + * Retrieves mining instruction from the SI chain for the given [blockHash] (or the best block hash + * if [block hash] is null). + */ + suspend fun getMiningInstruction(blockHash: String? = null): ApmInstruction - suspend fun submitVtbs(vtbs: List) = submit(emptyList(), emptyList(), vtbs) + suspend fun submitAtv(atv: AltPublication): ValidationState + suspend fun submitVtb(vtb: VeriBlockPublication): ValidationState + suspend fun submitVbk(vbk: VbkBlock): ValidationState /** * Extracts an address' display string from the given data (coming from the Mining Instruction) @@ -132,3 +130,9 @@ interface SecurityInheritingChain { */ suspend fun getBlockChainInfo(): StateInfo } + +data class ValidationState( + val valid: Boolean, + val code: String? = null, + val message: String? = null +) \ No newline at end of file From 9b73a982f385ab0951308ee35b58c47a3b48d5c2 Mon Sep 17 00:00:00 2001 From: Bohdan Vanieiev Date: Tue, 17 Nov 2020 14:38:17 +0200 Subject: [PATCH 2/2] Remove getId --- .../kotlin/org/veriblock/sdk/alt/SecurityInheritingChain.kt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/altchain-sdk/src/main/kotlin/org/veriblock/sdk/alt/SecurityInheritingChain.kt b/altchain-sdk/src/main/kotlin/org/veriblock/sdk/alt/SecurityInheritingChain.kt index e77d4c646..d3d80e512 100644 --- a/altchain-sdk/src/main/kotlin/org/veriblock/sdk/alt/SecurityInheritingChain.kt +++ b/altchain-sdk/src/main/kotlin/org/veriblock/sdk/alt/SecurityInheritingChain.kt @@ -25,11 +25,6 @@ interface SecurityInheritingChain { */ suspend fun getConfig(): ChainConfig - /** - * Returns this security inheriting chain's unique identifier. - */ - suspend fun getId(): Long - /** * Returns this security inheriting chain's key, usually the token symbol. */