Merged in rnicoll-rename (pull request #52)

Rename classes for network map service
This commit is contained in:
Ross Nicoll 2016-04-07 15:56:31 +01:00
commit de7e73cff3
22 changed files with 104 additions and 102 deletions

View File

@ -103,7 +103,7 @@ class Config(val services: ServiceHub): ContextResolver<ObjectMapper> {
} }
val mapper = parser.codec as ServiceHubObjectMapper val mapper = parser.codec as ServiceHubObjectMapper
// TODO this needs to use some industry identifier(s) not just these human readable names // TODO this needs to use some industry identifier(s) not just these human readable names
val nodeForPartyName = mapper.serviceHub.networkMapService.nodeForPartyName(parser.text) ?: throw JsonParseException("Could not find a Party with name: ${parser.text}", parser.currentLocation) val nodeForPartyName = mapper.serviceHub.networkMapCache.nodeForPartyName(parser.text) ?: throw JsonParseException("Could not find a Party with name: ${parser.text}", parser.currentLocation)
return nodeForPartyName.identity return nodeForPartyName.identity
} }
} }

View File

@ -44,7 +44,7 @@ import java.util.concurrent.Executors
* A base node implementation that can be customised either for production (with real implementations that do real * A base node implementation that can be customised either for production (with real implementations that do real
* I/O), or a mock implementation suitable for unit test environments. * I/O), or a mock implementation suitable for unit test environments.
*/ */
abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration, val timestamperAddress: LegallyIdentifiableNode?, val platformClock: Clock) { abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration, val timestamperAddress: NodeInfo?, val platformClock: Clock) {
companion object { companion object {
val PRIVATE_KEY_FILE_NAME = "identity-private-key" val PRIVATE_KEY_FILE_NAME = "identity-private-key"
val PUBLIC_IDENTITY_FILE_NAME = "identity-public" val PUBLIC_IDENTITY_FILE_NAME = "identity-public"
@ -63,7 +63,7 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
val services = object : ServiceHub { val services = object : ServiceHub {
override val networkService: MessagingService get() = net override val networkService: MessagingService get() = net
override val networkMapService: NetworkMapService = MockNetworkMapService() override val networkMapCache: NetworkMapCache = MockNetworkMapCache()
override val storageService: StorageService get() = storage override val storageService: StorageService get() = storage
override val walletService: WalletService get() = wallet override val walletService: WalletService get() = wallet
override val keyManagementService: KeyManagementService get() = keyManagement override val keyManagementService: KeyManagementService get() = keyManagement
@ -72,8 +72,8 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
override val clock: Clock get() = platformClock override val clock: Clock get() = platformClock
} }
val legallyIdentifiableAddress: LegallyIdentifiableNode by lazy { val info: NodeInfo by lazy {
LegallyIdentifiableNode(net.myAddress, storage.myLegalIdentity, findMyLocation()) NodeInfo(net.myAddress, storage.myLegalIdentity, findMyLocation())
} }
protected open fun findMyLocation(): PhysicalLocation? = CityDatabase[configuration.nearestCity] protected open fun findMyLocation(): PhysicalLocation? = CityDatabase[configuration.nearestCity]
@ -122,9 +122,9 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
timestamperAddress timestamperAddress
} else { } else {
inNodeTimestampingService = NodeTimestamperService(net, storage.myLegalIdentity, storage.myLegalIdentityKey, platformClock) inNodeTimestampingService = NodeTimestamperService(net, storage.myLegalIdentity, storage.myLegalIdentityKey, platformClock)
LegallyIdentifiableNode(net.myAddress, storage.myLegalIdentity) NodeInfo(net.myAddress, storage.myLegalIdentity)
} }
(services.networkMapService as MockNetworkMapService).timestampingNodes.add(tsid) (services.networkMapCache as MockNetworkMapCache).timestampingNodes.add(tsid)
identity = makeIdentityService() identity = makeIdentityService()

View File

@ -15,7 +15,7 @@ import com.codahale.metrics.JmxReporter
import com.google.common.net.HostAndPort import com.google.common.net.HostAndPort
import core.messaging.MessagingService import core.messaging.MessagingService
import core.node.services.ArtemisMessagingService import core.node.services.ArtemisMessagingService
import core.node.services.LegallyIdentifiableNode import core.node.services.NodeInfo
import core.node.servlets.AttachmentDownloadServlet import core.node.servlets.AttachmentDownloadServlet
import core.node.servlets.DataUploadServlet import core.node.servlets.DataUploadServlet
import core.utilities.loggerFor import core.utilities.loggerFor
@ -52,7 +52,7 @@ class ConfigurationException(message: String) : Exception(message)
* @param clock The clock used within the node and by all protocols etc * @param clock The clock used within the node and by all protocols etc
*/ */
class Node(dir: Path, val p2pAddr: HostAndPort, configuration: NodeConfiguration, class Node(dir: Path, val p2pAddr: HostAndPort, configuration: NodeConfiguration,
timestamperAddress: LegallyIdentifiableNode?, timestamperAddress: NodeInfo?,
clock: Clock = Clock.systemUTC()) : AbstractNode(dir, configuration, timestamperAddress, clock) { clock: Clock = Clock.systemUTC()) : AbstractNode(dir, configuration, timestamperAddress, clock) {
companion object { companion object {
/** The port that is used by default if none is specified. As you know, 31337 is the most elite number. */ /** The port that is used by default if none is specified. As you know, 31337 is the most elite number. */

View File

@ -13,9 +13,11 @@ import core.crypto.DummyPublicKey
import core.messaging.SingleMessageRecipient import core.messaging.SingleMessageRecipient
import java.util.* import java.util.*
/** Info about a network node that has operated by some sort of verified identity. */ /**
data class LegallyIdentifiableNode(val address: SingleMessageRecipient, val identity: Party, * Info about a network node that acts on behalf of some sort of verified identity.
val physicalLocation: PhysicalLocation? = null) */
data class NodeInfo(val address: SingleMessageRecipient, val identity: Party,
val physicalLocation: PhysicalLocation? = null)
/** /**
* A network map contains lists of nodes on the network along with information about their identity keys, services * A network map contains lists of nodes on the network along with information about their identity keys, services
@ -26,25 +28,25 @@ data class LegallyIdentifiableNode(val address: SingleMessageRecipient, val iden
* *
* This interface assumes fast, synchronous access to an in-memory map. * This interface assumes fast, synchronous access to an in-memory map.
*/ */
interface NetworkMapService { interface NetworkMapCache {
val timestampingNodes: List<LegallyIdentifiableNode> val timestampingNodes: List<NodeInfo>
val ratesOracleNodes: List<LegallyIdentifiableNode> val ratesOracleNodes: List<NodeInfo>
val partyNodes: List<LegallyIdentifiableNode> val partyNodes: List<NodeInfo>
fun nodeForPartyName(name: String): LegallyIdentifiableNode? = partyNodes.singleOrNull { it.identity.name == name } fun nodeForPartyName(name: String): NodeInfo? = partyNodes.singleOrNull { it.identity.name == name }
} }
// TODO: Move this to the test tree once a real network map is implemented and this scaffolding is no longer needed. // TODO: Move this to the test tree once a real network map is implemented and this scaffolding is no longer needed.
class MockNetworkMapService : NetworkMapService { class MockNetworkMapCache : NetworkMapCache {
data class MockAddress(val id: String): SingleMessageRecipient data class MockAddress(val id: String): SingleMessageRecipient
override val timestampingNodes = Collections.synchronizedList(ArrayList<LegallyIdentifiableNode>()) override val timestampingNodes = Collections.synchronizedList(ArrayList<NodeInfo>())
override val ratesOracleNodes = Collections.synchronizedList(ArrayList<LegallyIdentifiableNode>()) override val ratesOracleNodes = Collections.synchronizedList(ArrayList<NodeInfo>())
override val partyNodes = Collections.synchronizedList(ArrayList<LegallyIdentifiableNode>()) override val partyNodes = Collections.synchronizedList(ArrayList<NodeInfo>())
init { init {
partyNodes.add(LegallyIdentifiableNode(MockAddress("bankC:8080"), Party("Bank C", DummyPublicKey("Bank C")))) partyNodes.add(NodeInfo(MockAddress("bankC:8080"), Party("Bank C", DummyPublicKey("Bank C"))))
partyNodes.add(LegallyIdentifiableNode(MockAddress("bankD:8080"), Party("Bank D", DummyPublicKey("Bank D")))) partyNodes.add(NodeInfo(MockAddress("bankD:8080"), Party("Bank D", DummyPublicKey("Bank D"))))
} }
} }

View File

@ -187,7 +187,7 @@ interface ServiceHub {
val identityService: IdentityService val identityService: IdentityService
val storageService: StorageService val storageService: StorageService
val networkService: MessagingService val networkService: MessagingService
val networkMapService: NetworkMapService val networkMapCache: NetworkMapCache
val monitoringService: MonitoringService val monitoringService: MonitoringService
val clock: Clock val clock: Clock

View File

@ -15,7 +15,7 @@ import core.ThreadBox
import core.crypto.sha256 import core.crypto.sha256
import core.messaging.* import core.messaging.*
import core.node.services.DummyTimestampingAuthority import core.node.services.DummyTimestampingAuthority
import core.node.services.LegallyIdentifiableNode import core.node.services.NodeInfo
import core.node.services.NodeTimestamperService import core.node.services.NodeTimestamperService
import core.utilities.loggerFor import core.utilities.loggerFor
import rx.Observable import rx.Observable
@ -150,15 +150,15 @@ class InMemoryMessagingNetwork {
override fun hashCode() = id.hashCode() override fun hashCode() = id.hashCode()
} }
private var timestampingAdvert: LegallyIdentifiableNode? = null private var timestampingAdvert: NodeInfo? = null
@Synchronized @Synchronized
fun setupTimestampingNode(manuallyPumped: Boolean): Pair<LegallyIdentifiableNode, InMemoryMessaging> { fun setupTimestampingNode(manuallyPumped: Boolean): Pair<NodeInfo, InMemoryMessaging> {
check(timestampingAdvert == null) check(timestampingAdvert == null)
val (handle, builder) = createNode(manuallyPumped) val (handle, builder) = createNode(manuallyPumped)
val node = builder.start().get() val node = builder.start().get()
NodeTimestamperService(node, DummyTimestampingAuthority.identity, DummyTimestampingAuthority.key) NodeTimestamperService(node, DummyTimestampingAuthority.identity, DummyTimestampingAuthority.key)
timestampingAdvert = LegallyIdentifiableNode(handle, DummyTimestampingAuthority.identity) timestampingAdvert = NodeInfo(handle, DummyTimestampingAuthority.identity)
return Pair(timestampingAdvert!!, node) return Pair(timestampingAdvert!!, node)
} }

View File

@ -16,7 +16,7 @@ import core.messaging.SingleMessageRecipient
import core.node.AbstractNode import core.node.AbstractNode
import core.node.NodeConfiguration import core.node.NodeConfiguration
import core.node.services.FixedIdentityService import core.node.services.FixedIdentityService
import core.node.services.LegallyIdentifiableNode import core.node.services.NodeInfo
import core.node.services.PhysicalLocation import core.node.services.PhysicalLocation
import core.utilities.loggerFor import core.utilities.loggerFor
import org.slf4j.Logger import org.slf4j.Logger
@ -54,18 +54,18 @@ class MockNetwork(private val threadPerNode: Boolean = false,
/** Allows customisation of how nodes are created. */ /** Allows customisation of how nodes are created. */
interface Factory { interface Factory {
fun create(dir: Path, config: NodeConfiguration, network: MockNetwork, fun create(dir: Path, config: NodeConfiguration, network: MockNetwork,
timestamperAddr: LegallyIdentifiableNode?): MockNode timestamperAddr: NodeInfo?): MockNode
} }
object DefaultFactory : Factory { object DefaultFactory : Factory {
override fun create(dir: Path, config: NodeConfiguration, network: MockNetwork, override fun create(dir: Path, config: NodeConfiguration, network: MockNetwork,
timestamperAddr: LegallyIdentifiableNode?): MockNode { timestamperAddr: NodeInfo?): MockNode {
return MockNode(dir, config, network, timestamperAddr) return MockNode(dir, config, network, timestamperAddr)
} }
} }
open class MockNode(dir: Path, config: NodeConfiguration, val mockNet: MockNetwork, open class MockNode(dir: Path, config: NodeConfiguration, val mockNet: MockNetwork,
withTimestamper: LegallyIdentifiableNode?, val forcedID: Int = -1) : AbstractNode(dir, config, withTimestamper, Clock.systemUTC()) { withTimestamper: NodeInfo?, val forcedID: Int = -1) : AbstractNode(dir, config, withTimestamper, Clock.systemUTC()) {
override val log: Logger = loggerFor<MockNode>() override val log: Logger = loggerFor<MockNode>()
override val serverThread: ExecutorService = override val serverThread: ExecutorService =
if (mockNet.threadPerNode) if (mockNet.threadPerNode)
@ -96,7 +96,7 @@ class MockNetwork(private val threadPerNode: Boolean = false,
} }
/** Returns a started node, optionally created by the passed factory method */ /** Returns a started node, optionally created by the passed factory method */
fun createNode(withTimestamper: LegallyIdentifiableNode?, forcedID: Int = -1, nodeFactory: Factory = defaultFactory): MockNode { fun createNode(withTimestamper: NodeInfo?, forcedID: Int = -1, nodeFactory: Factory = defaultFactory): MockNode {
val newNode = forcedID == -1 val newNode = forcedID == -1
val id = if (newNode) counter++ else forcedID val id = if (newNode) counter++ else forcedID
@ -132,7 +132,7 @@ class MockNetwork(private val threadPerNode: Boolean = false,
*/ */
fun createTwoNodes(nodeFactory: Factory = defaultFactory): Pair<MockNode, MockNode> { fun createTwoNodes(nodeFactory: Factory = defaultFactory): Pair<MockNode, MockNode> {
require(nodes.isEmpty()) require(nodes.isEmpty())
return Pair(createNode(null, -1, nodeFactory), createNode(nodes[0].legallyIdentifiableAddress, -1, nodeFactory)) return Pair(createNode(null, -1, nodeFactory), createNode(nodes[0].info, -1, nodeFactory))
} }
fun addressToNode(address: SingleMessageRecipient): MockNode = nodes.single { it.net.myAddress == address } fun addressToNode(address: SingleMessageRecipient): MockNode = nodes.single { it.net.myAddress == address }

View File

@ -16,8 +16,8 @@ import core.node.Node
import core.node.NodeConfiguration import core.node.NodeConfiguration
import core.node.NodeConfigurationFromConfig import core.node.NodeConfigurationFromConfig
import core.node.services.ArtemisMessagingService import core.node.services.ArtemisMessagingService
import core.node.services.LegallyIdentifiableNode import core.node.services.NodeInfo
import core.node.services.MockNetworkMapService import core.node.services.MockNetworkMapCache
import core.serialization.deserialize import core.serialization.deserialize
import core.utilities.BriefLogFormatter import core.utilities.BriefLogFormatter
import joptsimple.OptionParser import joptsimple.OptionParser
@ -79,7 +79,7 @@ fun main(args: Array<String>) {
null null
} else { } else {
try { try {
legallyIdentifiableNode(options.valueOf(timestamperNetAddr), options.valueOf(timestamperIdentityFile)) nodeInfo(options.valueOf(timestamperNetAddr), options.valueOf(timestamperIdentityFile))
} catch (e: Exception) { } catch (e: Exception) {
null null
} }
@ -90,7 +90,7 @@ fun main(args: Array<String>) {
null null
} else { } else {
try { try {
legallyIdentifiableNode(options.valueOf(rateOracleNetAddr), options.valueOf(rateOracleIdentityFile)) nodeInfo(options.valueOf(rateOracleNetAddr), options.valueOf(rateOracleIdentityFile))
} catch (e: Exception) { } catch (e: Exception) {
null null
} }
@ -99,10 +99,10 @@ fun main(args: Array<String>) {
val node = logElapsedTime("Node startup") { Node(dir, myNetAddr, config, timestamperId, DemoClock()).start() } val node = logElapsedTime("Node startup") { Node(dir, myNetAddr, config, timestamperId, DemoClock()).start() }
// Add self to network map // Add self to network map
(node.services.networkMapService as MockNetworkMapService).partyNodes.add(node.legallyIdentifiableAddress) (node.services.networkMapCache as MockNetworkMapCache).partyNodes.add(node.info)
// Add rates oracle to network map // Add rates oracle to network map
(node.services.networkMapService as MockNetworkMapService).ratesOracleNodes.add(rateOracleId) (node.services.networkMapCache as MockNetworkMapCache).ratesOracleNodes.add(rateOracleId)
val hostAndPortStrings = options.valuesOf(fakeTradeWithAddr) val hostAndPortStrings = options.valuesOf(fakeTradeWithAddr)
val identityFiles = options.valuesOf(fakeTradeWithIdentityFile) val identityFiles = options.valuesOf(fakeTradeWithIdentityFile)
@ -111,8 +111,8 @@ fun main(args: Array<String>) {
} }
for ((hostAndPortString,identityFile) in hostAndPortStrings.zip(identityFiles)) { for ((hostAndPortString,identityFile) in hostAndPortStrings.zip(identityFiles)) {
try { try {
val peerId = legallyIdentifiableNode(hostAndPortString, identityFile) val peerId = nodeInfo(hostAndPortString, identityFile)
(node.services.networkMapService as MockNetworkMapService).partyNodes.add(peerId) (node.services.networkMapCache as MockNetworkMapCache).partyNodes.add(peerId)
} catch (e: Exception) { } catch (e: Exception) {
} }
} }
@ -128,12 +128,12 @@ fun main(args: Array<String>) {
exitProcess(0) exitProcess(0)
} }
fun legallyIdentifiableNode(hostAndPortString: String, identityFile: String): LegallyIdentifiableNode { fun nodeInfo(hostAndPortString: String, identityFile: String): NodeInfo {
try { try {
val addr = HostAndPort.fromString(hostAndPortString).withDefaultPort(Node.DEFAULT_PORT) val addr = HostAndPort.fromString(hostAndPortString).withDefaultPort(Node.DEFAULT_PORT)
val path = Paths.get(identityFile) val path = Paths.get(identityFile)
val party = Files.readAllBytes(path).deserialize<Party>(includeClassName = true) val party = Files.readAllBytes(path).deserialize<Party>(includeClassName = true)
return LegallyIdentifiableNode(ArtemisMessagingService.makeRecipient(addr), party) return NodeInfo(ArtemisMessagingService.makeRecipient(addr), party)
} catch (e: Exception) { } catch (e: Exception) {
println("Could not find identify file $identityFile. If the file has just been created as part of starting the demo, please restart this node") println("Could not find identify file $identityFile. If the file has just been created as part of starting the demo, please restart this node")
throw e throw e

View File

@ -13,7 +13,7 @@ import core.*
import core.node.Node import core.node.Node
import core.node.NodeConfiguration import core.node.NodeConfiguration
import core.node.services.ArtemisMessagingService import core.node.services.ArtemisMessagingService
import core.node.services.LegallyIdentifiableNode import core.node.services.NodeInfo
import core.node.services.NodeInterestRates import core.node.services.NodeInterestRates
import core.serialization.deserialize import core.serialization.deserialize
import core.utilities.ANSIProgressRenderer import core.utilities.ANSIProgressRenderer
@ -60,7 +60,7 @@ fun main(args: Array<String>) {
// Load oracle stuff (in lieu of having a network map service) // Load oracle stuff (in lieu of having a network map service)
val oracleAddr = ArtemisMessagingService.makeRecipient(options.valueOf(oracleAddrArg)) val oracleAddr = ArtemisMessagingService.makeRecipient(options.valueOf(oracleAddrArg))
val oracleIdentity = Files.readAllBytes(Paths.get(options.valueOf(oracleIdentityArg))).deserialize<Party>(includeClassName = true) val oracleIdentity = Files.readAllBytes(Paths.get(options.valueOf(oracleIdentityArg))).deserialize<Party>(includeClassName = true)
val oracleNode = LegallyIdentifiableNode(oracleAddr, oracleIdentity) val oracleNode = NodeInfo(oracleAddr, oracleIdentity)
val fixOf: FixOf = NodeInterestRates.parseFixOf(options.valueOf(fixOfArg)) val fixOf: FixOf = NodeInterestRates.parseFixOf(options.valueOf(fixOfArg))
val expectedRate = BigDecimal(options.valueOf(expectedRateArg)) val expectedRate = BigDecimal(options.valueOf(expectedRateArg))

View File

@ -20,7 +20,7 @@ import core.node.Node
import core.node.NodeConfiguration import core.node.NodeConfiguration
import core.node.NodeConfigurationFromConfig import core.node.NodeConfigurationFromConfig
import core.node.services.ArtemisMessagingService import core.node.services.ArtemisMessagingService
import core.node.services.LegallyIdentifiableNode import core.node.services.NodeInfo
import core.node.services.NodeAttachmentService import core.node.services.NodeAttachmentService
import core.node.services.NodeWalletService import core.node.services.NodeWalletService
import core.protocols.ProtocolLogic import core.protocols.ProtocolLogic
@ -95,7 +95,7 @@ fun main(args: Array<String>) {
val addr = HostAndPort.fromString(options.valueOf(timestamperNetAddr)).withDefaultPort(Node.DEFAULT_PORT) val addr = HostAndPort.fromString(options.valueOf(timestamperNetAddr)).withDefaultPort(Node.DEFAULT_PORT)
val path = Paths.get(options.valueOf(timestamperIdentityFile)) val path = Paths.get(options.valueOf(timestamperIdentityFile))
val party = Files.readAllBytes(path).deserialize<Party>(includeClassName = true) val party = Files.readAllBytes(path).deserialize<Party>(includeClassName = true)
LegallyIdentifiableNode(ArtemisMessagingService.makeRecipient(addr), party) NodeInfo(ArtemisMessagingService.makeRecipient(addr), party)
} else null } else null
val node = logElapsedTime("Node startup") { Node(dir, myNetAddr, config, timestamperId).start() } val node = logElapsedTime("Node startup") { Node(dir, myNetAddr, config, timestamperId).start() }
@ -163,7 +163,7 @@ class TraderDemoProtocolBuyer(private val attachmentsPath: Path) : ProtocolLogic
progressTracker.currentStep = STARTING_BUY progressTracker.currentStep = STARTING_BUY
send("test.junktrade", newPartnerAddr, 0, sessionID) send("test.junktrade", newPartnerAddr, 0, sessionID)
val tsa = serviceHub.networkMapService.timestampingNodes[0] val tsa = serviceHub.networkMapCache.timestampingNodes[0]
val buyer = TwoPartyTradeProtocol.Buyer(newPartnerAddr, tsa.identity, 1000.DOLLARS, val buyer = TwoPartyTradeProtocol.Buyer(newPartnerAddr, tsa.identity, 1000.DOLLARS,
CommercialPaper.State::class.java, sessionID) CommercialPaper.State::class.java, sessionID)
val tradeTX: SignedTransaction = subProtocol(buyer) val tradeTX: SignedTransaction = subProtocol(buyer)
@ -222,7 +222,7 @@ class TraderDemoProtocolSeller(val myAddress: HostAndPort,
progressTracker.currentStep = SELF_ISSUING progressTracker.currentStep = SELF_ISSUING
val tsa = serviceHub.networkMapService.timestampingNodes[0] val tsa = serviceHub.networkMapCache.timestampingNodes[0]
val cpOwnerKey = serviceHub.keyManagementService.freshKey() val cpOwnerKey = serviceHub.keyManagementService.freshKey()
val commercialPaper = selfIssueSomeCommercialPaper(cpOwnerKey.public, tsa) val commercialPaper = selfIssueSomeCommercialPaper(cpOwnerKey.public, tsa)
@ -236,7 +236,7 @@ class TraderDemoProtocolSeller(val myAddress: HostAndPort,
} }
@Suspendable @Suspendable
fun selfIssueSomeCommercialPaper(ownedBy: PublicKey, tsa: LegallyIdentifiableNode): StateAndRef<CommercialPaper.State> { fun selfIssueSomeCommercialPaper(ownedBy: PublicKey, tsa: NodeInfo): StateAndRef<CommercialPaper.State> {
// Make a fake company that's issued its own paper. // Make a fake company that's issued its own paper.
val keyPair = generateKeyPair() val keyPair = generateKeyPair()
val party = Party("Bank of London", keyPair.public) val party = Party("Bank of London", keyPair.public)

View File

@ -95,10 +95,10 @@ object AutoOfferProtocol {
override fun call(): SignedTransaction { override fun call(): SignedTransaction {
val ourSessionID = random63BitValue() val ourSessionID = random63BitValue()
val timestampingAuthority = serviceHub.networkMapService.timestampingNodes[0] val timestampingAuthority = serviceHub.networkMapCache.timestampingNodes[0]
// need to pick which ever party is not us // need to pick which ever party is not us
val otherParty = notUs(*dealToBeOffered.parties).single() val otherParty = notUs(*dealToBeOffered.parties).single()
val otherSide = (serviceHub.networkMapService.nodeForPartyName(otherParty.name))!!.address val otherSide = (serviceHub.networkMapCache.nodeForPartyName(otherParty.name))!!.address
progressTracker.currentStep = ANNOUNCING progressTracker.currentStep = ANNOUNCING
send(TOPIC, otherSide, 0, AutoOfferMessage(serviceHub.networkService.myAddress, ourSessionID, dealToBeOffered)) send(TOPIC, otherSide, 0, AutoOfferMessage(serviceHub.networkService.myAddress, ourSessionID, dealToBeOffered))
progressTracker.currentStep = DEALING progressTracker.currentStep = DEALING

View File

@ -3,8 +3,8 @@ package demos.protocols
import co.paralleluniverse.fibers.Suspendable import co.paralleluniverse.fibers.Suspendable
import co.paralleluniverse.strands.Strand import co.paralleluniverse.strands.Strand
import core.node.Node import core.node.Node
import core.node.services.LegallyIdentifiableNode import core.node.services.NodeInfo
import core.node.services.MockNetworkMapService import core.node.services.MockNetworkMapCache
import core.protocols.ProtocolLogic import core.protocols.ProtocolLogic
import core.serialization.deserialize import core.serialization.deserialize
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
@ -45,7 +45,7 @@ object ExitServerProtocol {
val rc = exitCode.toInt() val rc = exitCode.toInt()
val message = ExitMessage(rc) val message = ExitMessage(rc)
for (recipient in serviceHub.networkMapService.partyNodes) { for (recipient in serviceHub.networkMapCache.partyNodes) {
doNextRecipient(recipient, message) doNextRecipient(recipient, message)
} }
// Sleep a little in case any async message delivery to other nodes needs to happen // Sleep a little in case any async message delivery to other nodes needs to happen
@ -56,8 +56,8 @@ object ExitServerProtocol {
} }
@Suspendable @Suspendable
private fun doNextRecipient(recipient: LegallyIdentifiableNode, message: ExitMessage) { private fun doNextRecipient(recipient: NodeInfo, message: ExitMessage) {
if(recipient.address is MockNetworkMapService.MockAddress) { if(recipient.address is MockNetworkMapCache.MockAddress) {
// Ignore // Ignore
} else { } else {
// TODO: messaging ourselves seems to trigger a bug for the time being and we continuously receive messages // TODO: messaging ourselves seems to trigger a bug for the time being and we continuously receive messages

View File

@ -6,8 +6,8 @@ import contracts.DealState
import contracts.InterestRateSwap import contracts.InterestRateSwap
import core.StateAndRef import core.StateAndRef
import core.node.Node import core.node.Node
import core.node.services.LegallyIdentifiableNode import core.node.services.NodeInfo
import core.node.services.MockNetworkMapService import core.node.services.MockNetworkMapCache
import core.protocols.ProtocolLogic import core.protocols.ProtocolLogic
import core.random63BitValue import core.random63BitValue
import core.serialization.deserialize import core.serialization.deserialize
@ -57,14 +57,14 @@ object UpdateBusinessDayProtocol {
} }
// This assumes we definitely have one key or the other // This assumes we definitely have one key or the other
fun otherParty(deal: DealState): LegallyIdentifiableNode { fun otherParty(deal: DealState): NodeInfo {
val ourKeys = serviceHub.keyManagementService.keys.keys val ourKeys = serviceHub.keyManagementService.keys.keys
return serviceHub.networkMapService.nodeForPartyName(deal.parties.single { !ourKeys.contains(it.owningKey) }.name)!! return serviceHub.networkMapCache.nodeForPartyName(deal.parties.single { !ourKeys.contains(it.owningKey) }.name)!!
} }
// TODO we should make this more object oriented when we can ask a state for it's contract // TODO we should make this more object oriented when we can ask a state for it's contract
@Suspendable @Suspendable
fun processDeal(party: LegallyIdentifiableNode, deal: StateAndRef<DealState>, date: LocalDate, sessionID: Long) { fun processDeal(party: NodeInfo, deal: StateAndRef<DealState>, date: LocalDate, sessionID: Long) {
when(deal.state) { when(deal.state) {
is InterestRateSwap.State -> processInterestRateSwap(party, StateAndRef(deal.state as InterestRateSwap.State, deal.ref), date, sessionID) is InterestRateSwap.State -> processInterestRateSwap(party, StateAndRef(deal.state as InterestRateSwap.State, deal.ref), date, sessionID)
} }
@ -72,7 +72,7 @@ object UpdateBusinessDayProtocol {
// TODO and this would move to the InterestRateSwap and cope with permutations of Fixed/Floating and Floating/Floating etc // TODO and this would move to the InterestRateSwap and cope with permutations of Fixed/Floating and Floating/Floating etc
@Suspendable @Suspendable
fun processInterestRateSwap(party: LegallyIdentifiableNode, deal: StateAndRef<InterestRateSwap.State>, date: LocalDate, sessionID: Long) { fun processInterestRateSwap(party: NodeInfo, deal: StateAndRef<InterestRateSwap.State>, date: LocalDate, sessionID: Long) {
var dealStateAndRef: StateAndRef<InterestRateSwap.State>? = deal var dealStateAndRef: StateAndRef<InterestRateSwap.State>? = deal
var nextFixingDate = deal.state.calculation.nextFixingDate() var nextFixingDate = deal.state.calculation.nextFixingDate()
while (nextFixingDate != null && !nextFixingDate.isAfter(date)) { while (nextFixingDate != null && !nextFixingDate.isAfter(date)) {
@ -93,22 +93,22 @@ object UpdateBusinessDayProtocol {
} }
@Suspendable @Suspendable
private fun nextFixingFloatingLeg(dealStateAndRef: StateAndRef<InterestRateSwap.State>, party: LegallyIdentifiableNode, sessionID: Long): StateAndRef<InterestRateSwap.State>? { private fun nextFixingFloatingLeg(dealStateAndRef: StateAndRef<InterestRateSwap.State>, party: NodeInfo, sessionID: Long): StateAndRef<InterestRateSwap.State>? {
progressTracker.childrenFor[FIXING] = TwoPartyDealProtocol.Primary.tracker() progressTracker.childrenFor[FIXING] = TwoPartyDealProtocol.Primary.tracker()
progressTracker.currentStep = FIXING progressTracker.currentStep = FIXING
val participant = TwoPartyDealProtocol.Floater(party.address, sessionID, serviceHub.networkMapService.timestampingNodes[0], dealStateAndRef, serviceHub.keyManagementService.freshKey(), sessionID, progressTracker.childrenFor[FIXING]!!) val participant = TwoPartyDealProtocol.Floater(party.address, sessionID, serviceHub.networkMapCache.timestampingNodes[0], dealStateAndRef, serviceHub.keyManagementService.freshKey(), sessionID, progressTracker.childrenFor[FIXING]!!)
Strand.sleep(100) Strand.sleep(100)
val result = subProtocol(participant) val result = subProtocol(participant)
return result.tx.outRef(0) return result.tx.outRef(0)
} }
@Suspendable @Suspendable
private fun nextFixingFixedLeg(dealStateAndRef: StateAndRef<InterestRateSwap.State>, party: LegallyIdentifiableNode, sessionID: Long): StateAndRef<InterestRateSwap.State>? { private fun nextFixingFixedLeg(dealStateAndRef: StateAndRef<InterestRateSwap.State>, party: NodeInfo, sessionID: Long): StateAndRef<InterestRateSwap.State>? {
progressTracker.childrenFor[FIXING] = TwoPartyDealProtocol.Secondary.tracker() progressTracker.childrenFor[FIXING] = TwoPartyDealProtocol.Secondary.tracker()
progressTracker.currentStep = FIXING progressTracker.currentStep = FIXING
val participant = TwoPartyDealProtocol.Fixer(party.address, serviceHub.networkMapService.timestampingNodes[0].identity, dealStateAndRef, sessionID, progressTracker.childrenFor[FIXING]!!) val participant = TwoPartyDealProtocol.Fixer(party.address, serviceHub.networkMapCache.timestampingNodes[0].identity, dealStateAndRef, sessionID, progressTracker.childrenFor[FIXING]!!)
val result = subProtocol(participant) val result = subProtocol(participant)
return result.tx.outRef(0) return result.tx.outRef(0)
} }
@ -147,7 +147,7 @@ object UpdateBusinessDayProtocol {
override fun call(): Boolean { override fun call(): Boolean {
val message = UpdateBusinessDayMessage(date, random63BitValue()) val message = UpdateBusinessDayMessage(date, random63BitValue())
for (recipient in serviceHub.networkMapService.partyNodes) { for (recipient in serviceHub.networkMapCache.partyNodes) {
progressTracker.currentStep = NOTIFYING progressTracker.currentStep = NOTIFYING
doNextRecipient(recipient, message) doNextRecipient(recipient, message)
} }
@ -159,8 +159,8 @@ object UpdateBusinessDayProtocol {
} }
@Suspendable @Suspendable
private fun doNextRecipient(recipient: LegallyIdentifiableNode, message: UpdateBusinessDayMessage) { private fun doNextRecipient(recipient: NodeInfo, message: UpdateBusinessDayMessage) {
if(recipient.address is MockNetworkMapService.MockAddress) { if(recipient.address is MockNetworkMapCache.MockAddress) {
// Ignore // Ignore
} else { } else {
// TODO: messaging ourselves seems to trigger a bug for the time being and we continuously receive messages // TODO: messaging ourselves seems to trigger a bug for the time being and we continuously receive messages

View File

@ -12,7 +12,7 @@ import co.paralleluniverse.fibers.Suspendable
import core.* import core.*
import core.crypto.DigitalSignature import core.crypto.DigitalSignature
import core.messaging.SingleMessageRecipient import core.messaging.SingleMessageRecipient
import core.node.services.LegallyIdentifiableNode import core.node.services.NodeInfo
import core.protocols.ProtocolLogic import core.protocols.ProtocolLogic
import core.utilities.ProgressTracker import core.utilities.ProgressTracker
import java.math.BigDecimal import java.math.BigDecimal
@ -29,7 +29,7 @@ import java.util.*
* @throws FixOutOfRange if the returned fix was further away from the expected rate by the given amount. * @throws FixOutOfRange if the returned fix was further away from the expected rate by the given amount.
*/ */
open class RatesFixProtocol(protected val tx: TransactionBuilder, open class RatesFixProtocol(protected val tx: TransactionBuilder,
private val oracle: LegallyIdentifiableNode, private val oracle: NodeInfo,
private val fixOf: FixOf, private val fixOf: FixOf,
private val expectedRate: BigDecimal, private val expectedRate: BigDecimal,
private val rateTolerance: BigDecimal) : ProtocolLogic<Unit>() { private val rateTolerance: BigDecimal) : ProtocolLogic<Unit>() {

View File

@ -14,7 +14,7 @@ import core.WireTransaction
import core.crypto.DigitalSignature import core.crypto.DigitalSignature
import core.messaging.MessageRecipients import core.messaging.MessageRecipients
import core.messaging.StateMachineManager import core.messaging.StateMachineManager
import core.node.services.LegallyIdentifiableNode import core.node.services.NodeInfo
import core.node.services.NodeTimestamperService import core.node.services.NodeTimestamperService
import core.node.services.TimestamperService import core.node.services.TimestamperService
import core.protocols.ProtocolLogic import core.protocols.ProtocolLogic
@ -31,11 +31,11 @@ import core.utilities.ProgressTracker
* the built transaction. Please be aware that this will block, meaning it should not be used on a thread that is handling * the built transaction. Please be aware that this will block, meaning it should not be used on a thread that is handling
* a network message: use it only from spare application threads that don't have to respond to anything. * a network message: use it only from spare application threads that don't have to respond to anything.
*/ */
class TimestampingProtocol(private val node: LegallyIdentifiableNode, class TimestampingProtocol(private val node: NodeInfo,
private val wtxBytes: SerializedBytes<WireTransaction>, private val wtxBytes: SerializedBytes<WireTransaction>,
override val progressTracker: ProgressTracker = TimestampingProtocol.tracker()) : ProtocolLogic<DigitalSignature.LegallyIdentifiable>() { override val progressTracker: ProgressTracker = TimestampingProtocol.tracker()) : ProtocolLogic<DigitalSignature.LegallyIdentifiable>() {
class Client(private val stateMachineManager: StateMachineManager, private val node: LegallyIdentifiableNode) : TimestamperService { class Client(private val stateMachineManager: StateMachineManager, private val node: NodeInfo) : TimestamperService {
override val identity: Party = node.identity override val identity: Party = node.identity
override fun timestamp(wtxBytes: SerializedBytes<WireTransaction>): DigitalSignature.LegallyIdentifiable { override fun timestamp(wtxBytes: SerializedBytes<WireTransaction>): DigitalSignature.LegallyIdentifiable {

View File

@ -15,7 +15,7 @@ import core.*
import core.crypto.DigitalSignature import core.crypto.DigitalSignature
import core.crypto.signWithECDSA import core.crypto.signWithECDSA
import core.messaging.SingleMessageRecipient import core.messaging.SingleMessageRecipient
import core.node.services.LegallyIdentifiableNode import core.node.services.NodeInfo
import core.protocols.ProtocolLogic import core.protocols.ProtocolLogic
import core.utilities.ProgressTracker import core.utilities.ProgressTracker
import core.utilities.UntrustworthyData import core.utilities.UntrustworthyData
@ -63,7 +63,7 @@ object TwoPartyDealProtocol {
val otherSide: SingleMessageRecipient, val otherSide: SingleMessageRecipient,
val otherSessionID: Long, val otherSessionID: Long,
val myKeyPair: KeyPair, val myKeyPair: KeyPair,
val timestampingAuthority: LegallyIdentifiableNode, val timestampingAuthority: NodeInfo,
override val progressTracker: ProgressTracker = Primary.tracker()) : ProtocolLogic<SignedTransaction>() { override val progressTracker: ProgressTracker = Primary.tracker()) : ProtocolLogic<SignedTransaction>() {
companion object { companion object {
@ -263,7 +263,7 @@ object TwoPartyDealProtocol {
* One side of the protocol for inserting a pre-agreed deal. * One side of the protocol for inserting a pre-agreed deal.
*/ */
open class Instigator<T : DealState>(otherSide: SingleMessageRecipient, open class Instigator<T : DealState>(otherSide: SingleMessageRecipient,
timestampingAuthority: LegallyIdentifiableNode, timestampingAuthority: NodeInfo,
dealBeingOffered: T, dealBeingOffered: T,
myKeyPair: KeyPair, myKeyPair: KeyPair,
buyerSessionID: Long, buyerSessionID: Long,
@ -360,7 +360,7 @@ object TwoPartyDealProtocol {
val oldRef = dealToFix.ref val oldRef = dealToFix.ref
val ptx = TransactionBuilder() val ptx = TransactionBuilder()
val addFixing = object : RatesFixProtocol(ptx, serviceHub.networkMapService.ratesOracleNodes[0], fixOf, BigDecimal.ZERO, BigDecimal.ONE) { val addFixing = object : RatesFixProtocol(ptx, serviceHub.networkMapCache.ratesOracleNodes[0], fixOf, BigDecimal.ZERO, BigDecimal.ONE) {
@Suspendable @Suspendable
override fun beforeSigning(fix: Fix) { override fun beforeSigning(fix: Fix) {
@ -387,7 +387,7 @@ object TwoPartyDealProtocol {
*/ */
open class Floater<T : FixableDealState>(otherSide: SingleMessageRecipient, open class Floater<T : FixableDealState>(otherSide: SingleMessageRecipient,
otherSessionID: Long, otherSessionID: Long,
timestampingAuthority: LegallyIdentifiableNode, timestampingAuthority: NodeInfo,
dealToFix: StateAndRef<T>, dealToFix: StateAndRef<T>,
myKeyPair: KeyPair, myKeyPair: KeyPair,
val sessionID: Long, val sessionID: Long,

View File

@ -17,7 +17,7 @@ import core.crypto.DigitalSignature
import core.crypto.signWithECDSA import core.crypto.signWithECDSA
import core.messaging.SingleMessageRecipient import core.messaging.SingleMessageRecipient
import core.messaging.StateMachineManager import core.messaging.StateMachineManager
import core.node.services.LegallyIdentifiableNode import core.node.services.NodeInfo
import core.protocols.ProtocolLogic import core.protocols.ProtocolLogic
import core.utilities.ProgressTracker import core.utilities.ProgressTracker
import core.utilities.trace import core.utilities.trace
@ -52,14 +52,14 @@ import java.time.Instant
object TwoPartyTradeProtocol { object TwoPartyTradeProtocol {
val TRADE_TOPIC = "platform.trade" val TRADE_TOPIC = "platform.trade"
fun runSeller(smm: StateMachineManager, timestampingAuthority: LegallyIdentifiableNode, fun runSeller(smm: StateMachineManager, timestampingAuthority: NodeInfo,
otherSide: SingleMessageRecipient, assetToSell: StateAndRef<OwnableState>, price: Amount, otherSide: SingleMessageRecipient, assetToSell: StateAndRef<OwnableState>, price: Amount,
myKeyPair: KeyPair, buyerSessionID: Long): ListenableFuture<SignedTransaction> { myKeyPair: KeyPair, buyerSessionID: Long): ListenableFuture<SignedTransaction> {
val seller = Seller(otherSide, timestampingAuthority, assetToSell, price, myKeyPair, buyerSessionID) val seller = Seller(otherSide, timestampingAuthority, assetToSell, price, myKeyPair, buyerSessionID)
return smm.add("${TRADE_TOPIC}.seller", seller) return smm.add("${TRADE_TOPIC}.seller", seller)
} }
fun runBuyer(smm: StateMachineManager, timestampingAuthority: LegallyIdentifiableNode, fun runBuyer(smm: StateMachineManager, timestampingAuthority: NodeInfo,
otherSide: SingleMessageRecipient, acceptablePrice: Amount, typeToBuy: Class<out OwnableState>, otherSide: SingleMessageRecipient, acceptablePrice: Amount, typeToBuy: Class<out OwnableState>,
sessionID: Long): ListenableFuture<SignedTransaction> { sessionID: Long): ListenableFuture<SignedTransaction> {
val buyer = Buyer(otherSide, timestampingAuthority.identity, acceptablePrice, typeToBuy, sessionID) val buyer = Buyer(otherSide, timestampingAuthority.identity, acceptablePrice, typeToBuy, sessionID)
@ -82,7 +82,7 @@ object TwoPartyTradeProtocol {
class SignaturesFromSeller(val timestampAuthoritySig: DigitalSignature.WithKey, val sellerSig: DigitalSignature.WithKey) class SignaturesFromSeller(val timestampAuthoritySig: DigitalSignature.WithKey, val sellerSig: DigitalSignature.WithKey)
open class Seller(val otherSide: SingleMessageRecipient, open class Seller(val otherSide: SingleMessageRecipient,
val timestampingAuthority: LegallyIdentifiableNode, val timestampingAuthority: NodeInfo,
val assetToSell: StateAndRef<OwnableState>, val assetToSell: StateAndRef<OwnableState>,
val price: Amount, val price: Amount,
val myKeyPair: KeyPair, val myKeyPair: KeyPair,

View File

@ -129,7 +129,7 @@ class MockServices(
val net: MessagingService? = null, val net: MessagingService? = null,
val identity: IdentityService? = MockIdentityService, val identity: IdentityService? = MockIdentityService,
val storage: StorageService? = MockStorageService(), val storage: StorageService? = MockStorageService(),
val networkMap: NetworkMapService? = MockNetworkMapService(), val networkMap: NetworkMapCache? = MockNetworkMapCache(),
val overrideClock: Clock? = Clock.systemUTC() val overrideClock: Clock? = Clock.systemUTC()
) : ServiceHub { ) : ServiceHub {
override val walletService: WalletService override val walletService: WalletService
@ -140,7 +140,7 @@ class MockServices(
get() = identity ?: throw UnsupportedOperationException() get() = identity ?: throw UnsupportedOperationException()
override val networkService: MessagingService override val networkService: MessagingService
get() = net ?: throw UnsupportedOperationException() get() = net ?: throw UnsupportedOperationException()
override val networkMapService: NetworkMapService override val networkMapCache: NetworkMapCache
get() = networkMap ?: throw UnsupportedOperationException() get() = networkMap ?: throw UnsupportedOperationException()
override val storageService: StorageService override val storageService: StorageService
get() = storage ?: throw UnsupportedOperationException() get() = storage ?: throw UnsupportedOperationException()

View File

@ -12,7 +12,7 @@ import core.Attachment
import core.crypto.SecureHash import core.crypto.SecureHash
import core.crypto.sha256 import core.crypto.sha256
import core.node.NodeConfiguration import core.node.NodeConfiguration
import core.node.services.LegallyIdentifiableNode import core.node.services.NodeInfo
import core.node.services.NodeAttachmentService import core.node.services.NodeAttachmentService
import core.serialization.OpaqueBytes import core.serialization.OpaqueBytes
import core.testing.MockNetwork import core.testing.MockNetwork
@ -94,7 +94,7 @@ class AttachmentTests {
fun maliciousResponse() { fun maliciousResponse() {
// Make a node that doesn't do sanity checking at load time. // Make a node that doesn't do sanity checking at load time.
val n0 = network.createNode(null, nodeFactory = object : MockNetwork.Factory { val n0 = network.createNode(null, nodeFactory = object : MockNetwork.Factory {
override fun create(dir: Path, config: NodeConfiguration, network: MockNetwork, timestamperAddr: LegallyIdentifiableNode?): MockNetwork.MockNode { override fun create(dir: Path, config: NodeConfiguration, network: MockNetwork, timestamperAddr: NodeInfo?): MockNetwork.MockNode {
return object : MockNetwork.MockNode(dir, config, network, timestamperAddr) { return object : MockNetwork.MockNode(dir, config, network, timestamperAddr) {
override fun start(): MockNetwork.MockNode { override fun start(): MockNetwork.MockNode {
super.start() super.start()
@ -104,7 +104,7 @@ class AttachmentTests {
} }
} }
}) })
val n1 = network.createNode(n0.legallyIdentifiableAddress) val n1 = network.createNode(n0.info)
// Insert an attachment into node zero's store directly. // Insert an attachment into node zero's store directly.
val id = n0.storage.attachments.importAttachment(ByteArrayInputStream(fakeAttachment())) val id = n0.storage.attachments.importAttachment(ByteArrayInputStream(fakeAttachment()))

View File

@ -66,7 +66,7 @@ class TwoPartyTradeProtocolTests : TestWithInMemoryNetwork() {
transactionGroupFor<ContractState> { transactionGroupFor<ContractState> {
val (aliceNode, bobNode) = net.createTwoNodes() val (aliceNode, bobNode) = net.createTwoNodes()
(bobNode.wallet as NodeWalletService).fillWithSomeTestCash(2000.DOLLARS) (bobNode.wallet as NodeWalletService).fillWithSomeTestCash(2000.DOLLARS)
val alicesFakePaper = fillUpForSeller(false, aliceNode.legallyIdentifiableAddress.identity, null).second val alicesFakePaper = fillUpForSeller(false, aliceNode.info.identity, null).second
insertFakeTransactions(alicesFakePaper, aliceNode.services, aliceNode.storage.myLegalIdentityKey) insertFakeTransactions(alicesFakePaper, aliceNode.services, aliceNode.storage.myLegalIdentityKey)
@ -74,7 +74,7 @@ class TwoPartyTradeProtocolTests : TestWithInMemoryNetwork() {
val aliceResult = TwoPartyTradeProtocol.runSeller( val aliceResult = TwoPartyTradeProtocol.runSeller(
aliceNode.smm, aliceNode.smm,
aliceNode.legallyIdentifiableAddress, aliceNode.info,
bobNode.net.myAddress, bobNode.net.myAddress,
lookup("alice's paper"), lookup("alice's paper"),
1000.DOLLARS, 1000.DOLLARS,
@ -83,7 +83,7 @@ class TwoPartyTradeProtocolTests : TestWithInMemoryNetwork() {
) )
val bobResult = TwoPartyTradeProtocol.runBuyer( val bobResult = TwoPartyTradeProtocol.runBuyer(
bobNode.smm, bobNode.smm,
aliceNode.legallyIdentifiableAddress, aliceNode.info,
aliceNode.net.myAddress, aliceNode.net.myAddress,
1000.DOLLARS, 1000.DOLLARS,
CommercialPaper.State::class.java, CommercialPaper.State::class.java,
@ -105,7 +105,7 @@ class TwoPartyTradeProtocolTests : TestWithInMemoryNetwork() {
var (aliceNode, bobNode) = net.createTwoNodes() var (aliceNode, bobNode) = net.createTwoNodes()
val aliceAddr = aliceNode.net.myAddress val aliceAddr = aliceNode.net.myAddress
val bobAddr = bobNode.net.myAddress as InMemoryMessagingNetwork.Handle val bobAddr = bobNode.net.myAddress as InMemoryMessagingNetwork.Handle
val timestamperAddr = aliceNode.legallyIdentifiableAddress val timestamperAddr = aliceNode.info
(bobNode.wallet as NodeWalletService).fillWithSomeTestCash(2000.DOLLARS) (bobNode.wallet as NodeWalletService).fillWithSomeTestCash(2000.DOLLARS)
val alicesFakePaper = fillUpForSeller(false, timestamperAddr.identity, null).second val alicesFakePaper = fillUpForSeller(false, timestamperAddr.identity, null).second
@ -165,7 +165,7 @@ class TwoPartyTradeProtocolTests : TestWithInMemoryNetwork() {
// ... bring the node back up ... the act of constructing the SMM will re-register the message handlers // ... bring the node back up ... the act of constructing the SMM will re-register the message handlers
// that Bob was waiting on before the reboot occurred. // that Bob was waiting on before the reboot occurred.
bobNode = net.createNode(timestamperAddr, bobAddr.id, object : MockNetwork.Factory { bobNode = net.createNode(timestamperAddr, bobAddr.id, object : MockNetwork.Factory {
override fun create(dir: Path, config: NodeConfiguration, network: MockNetwork, timestamperAddr: LegallyIdentifiableNode?): MockNetwork.MockNode { override fun create(dir: Path, config: NodeConfiguration, network: MockNetwork, timestamperAddr: NodeInfo?): MockNetwork.MockNode {
return object : MockNetwork.MockNode(dir, config, net, timestamperAddr, bobAddr.id) { return object : MockNetwork.MockNode(dir, config, net, timestamperAddr, bobAddr.id) {
override fun initialiseStorageService(dir: Path): StorageService { override fun initialiseStorageService(dir: Path): StorageService {
val ss = super.initialiseStorageService(dir) val ss = super.initialiseStorageService(dir)
@ -196,7 +196,7 @@ class TwoPartyTradeProtocolTests : TestWithInMemoryNetwork() {
private fun makeNodeWithTracking(name: String): MockNetwork.MockNode { private fun makeNodeWithTracking(name: String): MockNetwork.MockNode {
// Create a node in the mock network ... // Create a node in the mock network ...
return net.createNode(null, nodeFactory = object : MockNetwork.Factory { return net.createNode(null, nodeFactory = object : MockNetwork.Factory {
override fun create(dir: Path, config: NodeConfiguration, network: MockNetwork, timestamperAddr: LegallyIdentifiableNode?): MockNetwork.MockNode { override fun create(dir: Path, config: NodeConfiguration, network: MockNetwork, timestamperAddr: NodeInfo?): MockNetwork.MockNode {
return object : MockNetwork.MockNode(dir, config, network, timestamperAddr) { return object : MockNetwork.MockNode(dir, config, network, timestamperAddr) {
// That constructs the storage service object in a customised way ... // That constructs the storage service object in a customised way ...
override fun constructStorageService(attachments: NodeAttachmentService, keypair: KeyPair, identity: Party, override fun constructStorageService(attachments: NodeAttachmentService, keypair: KeyPair, identity: Party,
@ -213,7 +213,7 @@ class TwoPartyTradeProtocolTests : TestWithInMemoryNetwork() {
fun checkDependenciesOfSaleAssetAreResolved() { fun checkDependenciesOfSaleAssetAreResolved() {
transactionGroupFor<ContractState> { transactionGroupFor<ContractState> {
val aliceNode = makeNodeWithTracking("alice") val aliceNode = makeNodeWithTracking("alice")
val timestamperAddr = aliceNode.legallyIdentifiableAddress val timestamperAddr = aliceNode.info
val bobNode = makeNodeWithTracking("bob") val bobNode = makeNodeWithTracking("bob")
// Insert a prospectus type attachment into the commercial paper transaction. // Insert a prospectus type attachment into the commercial paper transaction.
@ -324,7 +324,7 @@ class TwoPartyTradeProtocolTests : TestWithInMemoryNetwork() {
var (aliceNode, bobNode) = net.createTwoNodes() var (aliceNode, bobNode) = net.createTwoNodes()
val aliceAddr = aliceNode.net.myAddress val aliceAddr = aliceNode.net.myAddress
val bobAddr = bobNode.net.myAddress as InMemoryMessagingNetwork.Handle val bobAddr = bobNode.net.myAddress as InMemoryMessagingNetwork.Handle
val timestamperAddr = aliceNode.legallyIdentifiableAddress val timestamperAddr = aliceNode.info
val bobKey = bobNode.keyManagement.freshKey() val bobKey = bobNode.keyManagement.freshKey()
val bobsBadCash = fillUpForBuyer(bobError, bobKey.public).second val bobsBadCash = fillUpForBuyer(bobError, bobKey.public).second

View File

@ -58,14 +58,14 @@ class TimestamperNodeServiceTest : TestWithInMemoryNetwork() {
mockServices = MockServices(net = serviceMessaging.second, storage = MockStorageService()) mockServices = MockServices(net = serviceMessaging.second, storage = MockStorageService())
val timestampingNodeID = network.setupTimestampingNode(true).first val timestampingNodeID = network.setupTimestampingNode(true).first
(mockServices.networkMapService as MockNetworkMapService).timestampingNodes.add(timestampingNodeID) (mockServices.networkMapCache as MockNetworkMapCache).timestampingNodes.add(timestampingNodeID)
serverKey = timestampingNodeID.identity.owningKey serverKey = timestampingNodeID.identity.owningKey
// And a separate one to be tested directly, to make the unit tests a bit faster. // And a separate one to be tested directly, to make the unit tests a bit faster.
service = NodeTimestamperService(serviceMessaging.second, Party("Unit test suite", ALICE), ALICE_KEY) service = NodeTimestamperService(serviceMessaging.second, Party("Unit test suite", ALICE), ALICE_KEY)
} }
class TestPSM(val server: LegallyIdentifiableNode, val now: Instant) : ProtocolLogic<Boolean>() { class TestPSM(val server: NodeInfo, val now: Instant) : ProtocolLogic<Boolean>() {
@Suspendable @Suspendable
override fun call(): Boolean { override fun call(): Boolean {
val ptx = TransactionBuilder().apply { val ptx = TransactionBuilder().apply {
@ -86,7 +86,7 @@ class TimestamperNodeServiceTest : TestWithInMemoryNetwork() {
val psm = runNetwork { val psm = runNetwork {
val smm = StateMachineManager(MockServices(net = myMessaging.second), RunOnCallerThread) val smm = StateMachineManager(MockServices(net = myMessaging.second), RunOnCallerThread)
val logName = NodeTimestamperService.TIMESTAMPING_PROTOCOL_TOPIC val logName = NodeTimestamperService.TIMESTAMPING_PROTOCOL_TOPIC
val psm = TestPSM(mockServices.networkMapService.timestampingNodes[0], clock.instant()) val psm = TestPSM(mockServices.networkMapCache.timestampingNodes[0], clock.instant())
smm.add(logName, psm) smm.add(logName, psm)
} }
assertTrue(psm.isDone) assertTrue(psm.isDone)

View File

@ -93,7 +93,7 @@ class NodeInterestRatesTest {
val tx = TransactionBuilder() val tx = TransactionBuilder()
val fixOf = NodeInterestRates.parseFixOf("LIBOR 2016-03-16 1M") val fixOf = NodeInterestRates.parseFixOf("LIBOR 2016-03-16 1M")
val protocol = RatesFixProtocol(tx, n2.legallyIdentifiableAddress, fixOf, "0.675".bd, "0.1".bd) val protocol = RatesFixProtocol(tx, n2.info, fixOf, "0.675".bd, "0.1".bd)
BriefLogFormatter.initVerbose("rates") BriefLogFormatter.initVerbose("rates")
val future = n1.smm.add("rates", protocol) val future = n1.smm.add("rates", protocol)