Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propose new SI Chain Plugin Interface #232

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@ interface SecurityInheritingChain {
/**
* Common configuration for the chain.
*/
val config: ChainConfig

/**
* Returns this security inheriting chain's unique identifier.
*/
val id: Long
suspend fun getConfig(): ChainConfig

/**
* Returns this security inheriting chain's key, usually the token symbol.
Expand Down Expand Up @@ -71,41 +66,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<VeriBlockBlock>,
atvs: List<AltPublication>,
vtbs: List<VeriBlockPublication>
)

suspend fun submitContext(contextBlocks: List<VeriBlockBlock>) = submit(contextBlocks, emptyList(), emptyList())
suspend fun getPopMempool(): PopMempool

suspend fun submitAtvs(atvs: List<AltPublication>) = 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).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* if [block hash] is null).
* if [blockHash] is null).

*/
suspend fun getMiningInstruction(blockHash: String? = null): ApmInstruction

suspend fun submitVtbs(vtbs: List<VeriBlockPublication>) = 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)
Expand All @@ -132,3 +125,9 @@ interface SecurityInheritingChain {
*/
suspend fun getBlockChainInfo(): StateInfo
}

data class ValidationState(
val valid: Boolean,
val code: String? = null,
val message: String? = null
)