mirror of
https://github.com/corda/corda.git
synced 2025-06-17 14:48:16 +00:00
Introducing Platform Version and its use by the NMS for min version requirements for the network
This commit is contained in:
@ -50,6 +50,12 @@ sealed class StateMachineUpdate {
|
||||
// TODO: The use of Pairs throughout is unfriendly for Java interop.
|
||||
|
||||
interface CordaRPCOps : RPCOps {
|
||||
/**
|
||||
* Returns the RPC protocol version, which is the same the node's Platform Version. Exists since version 1 so guaranteed
|
||||
* to be present.
|
||||
*/
|
||||
override val protocolVersion: Int get() = nodeIdentity().platformVersion
|
||||
|
||||
/**
|
||||
* Returns a pair of currently in-progress state machine infos and an observable of future state machine adds/removes.
|
||||
*/
|
||||
|
@ -19,7 +19,7 @@ data class ServiceEntry(val info: ServiceInfo, val identity: Party)
|
||||
@CordaSerializable
|
||||
data class NodeInfo(val address: SingleMessageRecipient,
|
||||
val legalIdentity: Party,
|
||||
val version: Version,
|
||||
val platformVersion: Int,
|
||||
var advertisedServices: List<ServiceEntry> = emptyList(),
|
||||
val physicalLocation: PhysicalLocation? = null) {
|
||||
init {
|
||||
|
@ -1,35 +0,0 @@
|
||||
package net.corda.core.node
|
||||
|
||||
import net.corda.core.serialization.CordaSerializable
|
||||
import java.util.regex.Pattern
|
||||
|
||||
/**
|
||||
* Versions of the same [major] version but with different [minor] versions are considered compatible with each other. One
|
||||
* exception to this is when the major version is 0 - each different minor version should be considered incompatible.
|
||||
*
|
||||
* If two [Version]s are equal (i.e. [equals] returns true) but they are both [snapshot] then they may refer to different
|
||||
* builds of the node. [NodeVersionInfo.revision] would be required to differentiate the two.
|
||||
*/
|
||||
@CordaSerializable
|
||||
data class Version(val major: Int, val minor: Int, val patch: Int?, val snapshot: Boolean) {
|
||||
companion object {
|
||||
private val pattern = Pattern.compile("""(\d+)\.(\d+)(.(\d+))?(-SNAPSHOT)?""")
|
||||
|
||||
fun parse(string: String): Version {
|
||||
val matcher = pattern.matcher(string)
|
||||
require(matcher.matches())
|
||||
val patch = matcher.group(4)?.toInt()
|
||||
return Version(matcher.group(1).toInt(), matcher.group(2).toInt(), patch, matcher.group(5) != null)
|
||||
}
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
val sb = StringBuilder()
|
||||
sb.append(major, ".", minor)
|
||||
if(patch != null) sb.append(".", patch)
|
||||
if(snapshot) sb.append("-SNAPSHOT")
|
||||
return sb.toString()
|
||||
}
|
||||
}
|
||||
|
||||
data class NodeVersionInfo(val version: Version, val revision: String, val vendor: String)
|
17
core/src/main/kotlin/net/corda/core/node/VersionInfo.kt
Normal file
17
core/src/main/kotlin/net/corda/core/node/VersionInfo.kt
Normal file
@ -0,0 +1,17 @@
|
||||
package net.corda.core.node
|
||||
|
||||
/**
|
||||
* Encapsulates various pieces of version information of the node.
|
||||
*/
|
||||
data class VersionInfo(
|
||||
/**
|
||||
* Platform version of the node which is an integer value which increments on any release where any of the public
|
||||
* API of the entire Corda platform changes. This includes messaging, serialisation, node APIs, etc.
|
||||
*/
|
||||
val platformVersion: Int,
|
||||
/** Release version string of the node. */
|
||||
val releaseVersion: String,
|
||||
/** The exact version control commit ID of the node build. */
|
||||
val revision: String,
|
||||
/** The node vendor */
|
||||
val vendor: String)
|
@ -1,41 +0,0 @@
|
||||
package net.corda.core.node
|
||||
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.Assertions.assertThatThrownBy
|
||||
import org.junit.Test
|
||||
|
||||
class VersionTest {
|
||||
@Test
|
||||
fun `parse valid non-SNAPSHOT string`() {
|
||||
assertThat(Version.parse("1.2")).isEqualTo(Version(1, 2, null, false))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `parse valid SNAPSHOT string`() {
|
||||
assertThat(Version.parse("2.23-SNAPSHOT")).isEqualTo(Version(2, 23, null, true))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `parse string with just major number`() {
|
||||
assertThatThrownBy {
|
||||
Version.parse("2")
|
||||
}.isInstanceOf(IllegalArgumentException::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `parse string with unknown qualifier`() {
|
||||
assertThatThrownBy {
|
||||
Version.parse("2.3-TEST")
|
||||
}.isInstanceOf(IllegalArgumentException::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `parses patch version`() {
|
||||
assertThat(Version.parse("0.1.2")).isEqualTo(Version(0, 1, 2, false))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `parses snapshot patch version`() {
|
||||
assertThat(Version.parse("0.1.2-SNAPSHOT")).isEqualTo(Version(0, 1, 2, true))
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user