mirror of
https://github.com/corda/corda.git
synced 2024-12-19 04:57:58 +00:00
Add gating checks to fail gracefully between incompatible versions
This commit is contained in:
parent
086a406fc5
commit
aa74ae69c1
@ -17,4 +17,5 @@ object PlatformVersionSwitches {
|
|||||||
const val BATCH_DOWNLOAD_COUNTERPARTY_BACKCHAIN = 6
|
const val BATCH_DOWNLOAD_COUNTERPARTY_BACKCHAIN = 6
|
||||||
const val ENABLE_P2P_COMPRESSION = 7
|
const val ENABLE_P2P_COMPRESSION = 7
|
||||||
const val CERTIFICATE_ROTATION = 9
|
const val CERTIFICATE_ROTATION = 9
|
||||||
|
const val NEW_MESSAGE_ID_STRUCTURE = 9
|
||||||
}
|
}
|
@ -12,4 +12,6 @@ open class SessionRejectException(message: String) : CordaException(message) {
|
|||||||
class NotAFlow(val initiatorClass: Class<*>) : SessionRejectException("${initiatorClass.name} is not a flow")
|
class NotAFlow(val initiatorClass: Class<*>) : SessionRejectException("${initiatorClass.name} is not a flow")
|
||||||
|
|
||||||
class NotRegistered(val initiatorFlowClass: Class<out FlowLogic<*>>) : SessionRejectException("${initiatorFlowClass.name} is not registered")
|
class NotRegistered(val initiatorFlowClass: Class<out FlowLogic<*>>) : SessionRejectException("${initiatorFlowClass.name} is not registered")
|
||||||
|
|
||||||
|
class IncompatibleVersions(counterpartyPlatformVersion: Int, minRequiredVersion: Int) : SessionRejectException("The minimum platform version this node can communicate with ($minRequiredVersion) is larger than the platform version of your node ($counterpartyPlatformVersion)")
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import net.corda.core.flows.StateMachineRunId
|
|||||||
import net.corda.core.identity.Party
|
import net.corda.core.identity.Party
|
||||||
import net.corda.core.internal.FlowStateMachine
|
import net.corda.core.internal.FlowStateMachine
|
||||||
import net.corda.core.internal.FlowStateMachineHandle
|
import net.corda.core.internal.FlowStateMachineHandle
|
||||||
|
import net.corda.core.internal.PlatformVersionSwitches.NEW_MESSAGE_ID_STRUCTURE
|
||||||
import net.corda.core.internal.VisibleForTesting
|
import net.corda.core.internal.VisibleForTesting
|
||||||
import net.corda.core.internal.bufferUntilSubscribed
|
import net.corda.core.internal.bufferUntilSubscribed
|
||||||
import net.corda.core.internal.castIfPossible
|
import net.corda.core.internal.castIfPossible
|
||||||
@ -756,6 +757,12 @@ internal class SingleThreadedStateMachineManager(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun onSessionInit(sessionMessage: InitialSessionMessage, sender: Party, event: ExternalEvent.ExternalMessageEvent) {
|
private fun onSessionInit(sessionMessage: InitialSessionMessage, sender: Party, event: ExternalEvent.ExternalMessageEvent) {
|
||||||
|
if (event.receivedMessage.platformVersion < NEW_MESSAGE_ID_STRUCTURE) {
|
||||||
|
val error = SessionRejectException.IncompatibleVersions(event.receivedMessage.platformVersion, NEW_MESSAGE_ID_STRUCTURE)
|
||||||
|
flowHospital.sessionInitErrored(sessionMessage, sender, event, error)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val initiatedFlowFactory = getInitiatedFlowFactory(sessionMessage)
|
val initiatedFlowFactory = getInitiatedFlowFactory(sessionMessage)
|
||||||
val initiatedSessionId = event.receivedMessage.uniqueMessageId.sessionIdentifier
|
val initiatedSessionId = event.receivedMessage.uniqueMessageId.sessionIdentifier
|
||||||
|
Loading…
Reference in New Issue
Block a user