From 56067acd208b1b58f17cca85c0eb40ad0e9a1ff5 Mon Sep 17 00:00:00 2001 From: Dimos Raptis Date: Wed, 18 Mar 2020 14:37:04 +0000 Subject: [PATCH] [CORDA-3628] - Remove overloads for sendAll (#6078) --- core/src/main/kotlin/net/corda/core/flows/FlowLogic.kt | 4 ++-- docs/source/api-flows.rst | 2 +- .../kotlin/net/corda/node/services/messaging/Messaging.kt | 2 +- .../net/corda/node/services/messaging/MessagingExecutor.kt | 2 +- .../net/corda/node/services/messaging/P2PMessagingClient.kt | 2 +- .../net/corda/node/services/statemachine/FlowMessaging.kt | 2 +- .../node/services/statemachine/FlowParallelMessagingTests.kt | 2 +- .../corda/testing/node/internal/MockNodeMessagingService.kt | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/core/src/main/kotlin/net/corda/core/flows/FlowLogic.kt b/core/src/main/kotlin/net/corda/core/flows/FlowLogic.kt index 6a45d1b0b6..808c68fbe7 100644 --- a/core/src/main/kotlin/net/corda/core/flows/FlowLogic.kt +++ b/core/src/main/kotlin/net/corda/core/flows/FlowLogic.kt @@ -333,7 +333,7 @@ abstract class FlowLogic { @JvmOverloads fun sendAll(payload: Any, sessions: Set, maySkipCheckpoint: Boolean = false) { val sessionToPayload = sessions.map { it to payload }.toMap() - return sendAll(sessionToPayload, maySkipCheckpoint) + return sendAllMap(sessionToPayload, maySkipCheckpoint) } /** @@ -348,7 +348,7 @@ abstract class FlowLogic { */ @Suspendable @JvmOverloads - fun sendAll(payloadsPerSession: Map, maySkipCheckpoint: Boolean = false) { + fun sendAllMap(payloadsPerSession: Map, maySkipCheckpoint: Boolean = false) { val request = FlowIORequest.Send( sessionToMessage = serializePayloads(payloadsPerSession) ) diff --git a/docs/source/api-flows.rst b/docs/source/api-flows.rst index 257690b290..05d6033c74 100644 --- a/docs/source/api-flows.rst +++ b/docs/source/api-flows.rst @@ -272,7 +272,7 @@ In addition ``FlowLogic`` provides functions that can receive messages from mult * Receives from all ``FlowSession`` objects specified in the passed in list. The received types must be the same. * ``sendAll(payload: Any, sessions: Set)`` * Sends the ``payload`` object to all the provided ``FlowSession``\s. -* ``sendAll(payloadsPerSession: Map)`` +* ``sendAllMap(payloadsPerSession: Map)`` * Sends a potentially different payload to each ``FlowSession``, as specified by the provided ``payloadsPerSession``. .. note:: It's more efficient to call ``sendAndReceive`` instead of calling ``send`` and then ``receive``. It's also more efficient to call ``sendAll``/``receiveAll`` instead of multiple ``send``/``receive`` respectively. diff --git a/node/src/main/kotlin/net/corda/node/services/messaging/Messaging.kt b/node/src/main/kotlin/net/corda/node/services/messaging/Messaging.kt index a9be394ac9..d2f440ef93 100644 --- a/node/src/main/kotlin/net/corda/node/services/messaging/Messaging.kt +++ b/node/src/main/kotlin/net/corda/node/services/messaging/Messaging.kt @@ -91,7 +91,7 @@ interface MessagingService : ServiceLifecycleSupport { * @param addressedMessages The list of messages together with the recipients, retry ids and sequence keys. */ @Suspendable - fun send(addressedMessages: List) + fun sendAll(addressedMessages: List) /** * Returns an initialised [Message] with the current time, etc, already filled in. diff --git a/node/src/main/kotlin/net/corda/node/services/messaging/MessagingExecutor.kt b/node/src/main/kotlin/net/corda/node/services/messaging/MessagingExecutor.kt index 96a75c6e59..eead9f5698 100644 --- a/node/src/main/kotlin/net/corda/node/services/messaging/MessagingExecutor.kt +++ b/node/src/main/kotlin/net/corda/node/services/messaging/MessagingExecutor.kt @@ -54,7 +54,7 @@ class MessagingExecutor( } @Synchronized - fun send(messages: Map) { + fun sendAll(messages: Map) { messages.forEach { recipients, message -> send(message, recipients) } } diff --git a/node/src/main/kotlin/net/corda/node/services/messaging/P2PMessagingClient.kt b/node/src/main/kotlin/net/corda/node/services/messaging/P2PMessagingClient.kt index 8254c0138f..0fcb7a3ca7 100644 --- a/node/src/main/kotlin/net/corda/node/services/messaging/P2PMessagingClient.kt +++ b/node/src/main/kotlin/net/corda/node/services/messaging/P2PMessagingClient.kt @@ -511,7 +511,7 @@ class P2PMessagingClient(val config: NodeConfiguration, } @Suspendable - override fun send(addressedMessages: List) { + override fun sendAll(addressedMessages: List) { for ((message, target, sequenceKey) in addressedMessages) { send(message, target, sequenceKey) } diff --git a/node/src/main/kotlin/net/corda/node/services/statemachine/FlowMessaging.kt b/node/src/main/kotlin/net/corda/node/services/statemachine/FlowMessaging.kt index da371d6d25..24a6604ffc 100644 --- a/node/src/main/kotlin/net/corda/node/services/statemachine/FlowMessaging.kt +++ b/node/src/main/kotlin/net/corda/node/services/statemachine/FlowMessaging.kt @@ -64,7 +64,7 @@ class FlowMessagingImpl(val serviceHub: ServiceHubInternal): FlowMessaging { @Suspendable override fun sendSessionMessages(messageData: List) { val addressedMessages = messageData.map { createMessage(it.destination, it.sessionMessage, it.dedupId) } - serviceHub.networkService.send(addressedMessages) + serviceHub.networkService.sendAll(addressedMessages) } private fun createMessage(destination: Destination, message: SessionMessage, deduplicationId: SenderDeduplicationId): MessagingService.AddressedMessage { diff --git a/node/src/test/kotlin/net/corda/node/services/statemachine/FlowParallelMessagingTests.kt b/node/src/test/kotlin/net/corda/node/services/statemachine/FlowParallelMessagingTests.kt index 53f7d588ea..fd0e161255 100644 --- a/node/src/test/kotlin/net/corda/node/services/statemachine/FlowParallelMessagingTests.kt +++ b/node/src/test/kotlin/net/corda/node/services/statemachine/FlowParallelMessagingTests.kt @@ -165,7 +165,7 @@ class FlowParallelMessagingTests { Pair(session, messageType) }.toMap() - sendAll(messagesPerSession) + sendAllMap(messagesPerSession) val messages = receiveAll(String::class.java, messagesPerSession.keys.toList()) messages.map { it.unwrap { payload -> assertEquals("pong", payload) } } diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/MockNodeMessagingService.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/MockNodeMessagingService.kt index ac8b2606bc..3b81fbc2ef 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/MockNodeMessagingService.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/MockNodeMessagingService.kt @@ -161,7 +161,7 @@ class MockNodeMessagingService(private val configuration: NodeConfiguration, } } - override fun send(addressedMessages: List) { + override fun sendAll(addressedMessages: List) { for ((message, target, sequenceKey) in addressedMessages) { send(message, target, sequenceKey) }