BroadcastTransaction не зарегистрировано, Corda - PullRequest
0 голосов
/ 15 мая 2018

что при вызове BroadcastTransaction возникает следующая ошибка:

Party C=GB,L=London,O=Controller rejected session request: 
    class ee.ut.cs.examples.parking.flows.BroadcastTransaction is not registered 

Вот мой FlowLogic, который хочет вызвать BroadcastTransaction

package ee.ut.cs.examples.parking.flows

import co.paralleluniverse.fibers.Suspendable
import net.corda.core.contracts.Command
import net.corda.core.contracts.StateAndContract
import net.corda.core.flows.FinalityFlow
import net.corda.core.flows.FlowLogic
import net.corda.core.flows.StartableByRPC
import net.corda.core.identity.Party
import net.corda.core.transactions.SignedTransaction
import net.corda.core.transactions.TransactionBuilder
import ee.ut.cs.examples.parking.contracts.ParkingSpaceContract
import ee.ut.cs.examples.parking.structures.ParkingSpace

@StartableByRPC
class CreateParkingSpace(private val dayRate: Double, private val nightRate: Double) : FlowLogic<SignedTransaction>() {
    @Suspendable
    override fun call(): SignedTransaction {
        val notary: Party = serviceHub.networkMapCache.notaryIdentities.first()

        val parkingSpace = ParkingSpace(owner = ourIdentity, dayRate = dayRate, nightRate = nightRate)
        val createCommand = Command(ParkingSpaceContract.Commands.Create(), listOf(ourIdentity.owningKey))
        val outputState = StateAndContract(parkingSpace, ParkingSpaceContract.CONTRACT_REF)

        val utx = TransactionBuilder(notary = notary).withItems(outputState, createCommand)

        val stx = serviceHub.signInitialTransaction(utx)
        val ftx = subFlow(FinalityFlow(stx))

        subFlow(BroadcastTransaction(ftx))

        return ftx
    }


}

Вот трансляция транзакции:

import co.paralleluniverse.fibers.Suspendable
import net.corda.core.flows.FlowLogic
import net.corda.core.flows.InitiatingFlow
import net.corda.core.flows.SendTransactionFlow
import net.corda.core.transactions.SignedTransaction

/**
 * Filters out any notary identities and removes our identity, then broadcasts the [SignedTransaction] to all the
 * remaining identities.
 */
@InitiatingFlow
class BroadcastTransaction(val stx: SignedTransaction) : FlowLogic<Unit>() {

    @Suspendable
    override fun call() {
        // Get a list of all identities from the network map cache.
        val everyone = serviceHub.networkMapCache.allNodes.flatMap { it.legalIdentities }

        // Filter out the notary identities and remove our identity.
        val everyoneButMeAndNotary = everyone.filter { serviceHub.networkMapCache.isNotary(it).not() } - ourIdentity

        // Create a session for each remaining party.
        val sessions = everyoneButMeAndNotary.map { initiateFlow(it) }

        // Send the transaction to all the remaining parties.
        sessions.forEach { subFlow(SendTransactionFlow(it, stx)) }
    }

}

1 Ответ

0 голосов
/ 15 мая 2018

Это SessionRejectException.

Это выбрасывается, потому что узел, получающий сообщение от BroadcastTransaction, не имеет зарегистрированного потока для ответа на BroadcastTransaction.

Вам необходимо установить поток ответчика на принимающем узле формы:

@InitiatedBy(BroadcastTransaction::class)
class Responder(val counterpartySession: FlowSession) : FlowLogic<Unit>() {
    @Suspendable
    override fun call() {
        // TODO: Flow logic here.
    }
}
...