ENT-10110 LedgerRecovery parameters + flow return type change. (#7516)

This commit is contained in:
Jose Coll 2023-10-02 17:29:48 +01:00 committed by GitHub
parent 4e355b953b
commit b15ca0f394
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,36 +14,17 @@ import net.corda.core.utilities.ProgressTracker
@StartableByRPC
@InitiatingFlow
class LedgerRecoveryFlow(
private val recoveryPeers: Collection<Party>,
private val timeWindow: RecoveryTimeWindow? = null,
private val useAllNetworkNodes: Boolean = false,
private val transactionRole: TransactionRole = TransactionRole.ALL,
private val dryRun: Boolean = false,
private val optimisticInitiatorRecovery: Boolean = false,
override val progressTracker: ProgressTracker = ProgressTracker()) : FlowLogic<Map<SecureHash, RecoveryResult>>() {
private val parameters: LedgerRecoveryParameters,
override val progressTracker: ProgressTracker = ProgressTracker()) : FlowLogic<Long>() {
@CordaInternal
data class ExtraConstructorArgs(val recoveryPeers: Collection<Party>,
val timeWindow: RecoveryTimeWindow? = null,
val useAllNetworkNodes: Boolean,
val transactionRole: TransactionRole,
val dryRun: Boolean,
val optimisticInitiatorRecovery: Boolean)
data class ExtraConstructorArgs(val parameters: LedgerRecoveryParameters)
@CordaInternal
fun getExtraConstructorArgs() = ExtraConstructorArgs(recoveryPeers, timeWindow, useAllNetworkNodes, transactionRole, dryRun, optimisticInitiatorRecovery)
// unused constructors added to facilitate Node Shell command invocation
constructor(recoveryPeer: Party, timeWindow: RecoveryTimeWindow?) : this(setOf(recoveryPeer), timeWindow, false, TransactionRole.ALL, false, false)
constructor(recoveryPeer: Party, timeWindow: RecoveryTimeWindow?, dryRun: Boolean) : this(setOf(recoveryPeer), timeWindow, false, TransactionRole.ALL, dryRun, false)
constructor(timeWindow: RecoveryTimeWindow?, dryRun: Boolean) : this(emptySet(), timeWindow, false, TransactionRole.ALL, dryRun, false)
constructor(timeWindow: RecoveryTimeWindow?, dryRun: Boolean, optimisticInitiatorRecovery: Boolean) : this(emptySet(), timeWindow, false, TransactionRole.ALL, dryRun, optimisticInitiatorRecovery)
constructor(recoveryPeers: Collection<Party>, timeWindow: RecoveryTimeWindow?, dryRun: Boolean) : this(recoveryPeers, timeWindow, false, TransactionRole.ALL, dryRun, false)
constructor(recoveryPeers: Collection<Party>, timeWindow: RecoveryTimeWindow?, dryRun: Boolean, optimisticInitiatorRecovery: Boolean) : this(recoveryPeers, timeWindow, false, TransactionRole.ALL, dryRun, optimisticInitiatorRecovery)
fun getExtraConstructorArgs() = ExtraConstructorArgs(parameters)
@Suspendable
@Throws(LedgerRecoveryException::class)
override fun call(): Map<SecureHash, RecoveryResult> {
override fun call(): Long {
throw NotImplementedError("Enterprise only feature")
}
}
@ -59,6 +40,18 @@ class ReceiveLedgerRecoveryFlow constructor(private val otherSideSession: FlowSe
@CordaSerializable
class LedgerRecoveryException(message: String) : FlowException("Ledger recovery failed: $message")
data class LedgerRecoveryParameters(
val recoveryPeers: Collection<Party>,
val timeWindow: RecoveryTimeWindow? = null,
val useAllNetworkNodes: Boolean = false,
val transactionRole: TransactionRole = TransactionRole.ALL,
val dryRun: Boolean = false,
val optimisticInitiatorRecovery: Boolean = false,
val useTimeWindowNarrowing: Boolean = false,
val verboseLogging: Boolean = true,
val recoveryBatchSize: Int = 1000
)
/**
* This specifies which type of transactions to recover based on the transaction role of the recovering node
*/
@ -80,6 +73,3 @@ data class RecoveryResult(
val synchronisedInitiated: Boolean = false, // only attempted if [optimisticInitiatorRecovery] option set to true and [TransactionRecoveryType.INITIATOR]
val failureCause: String? = null // reason why a transaction failed to synchronise
)