mirror of
https://github.com/corda/corda.git
synced 2024-12-18 20:47:57 +00:00
ENT-2054: Logging improvements (#3397)
This commit is contained in:
parent
1004c0f534
commit
d4b982b9fb
@ -15,7 +15,7 @@ class NotaryException(
|
|||||||
val error: NotaryError,
|
val error: NotaryError,
|
||||||
/** Id of the transaction to be notarised. Can be _null_ if an error occurred before the id could be resolved. */
|
/** Id of the transaction to be notarised. Can be _null_ if an error occurred before the id could be resolved. */
|
||||||
val txId: SecureHash? = null
|
val txId: SecureHash? = null
|
||||||
) : FlowException("Unable to notarise transaction${txId ?: " "}: $error")
|
) : FlowException("Unable to notarise transaction ${txId ?: "<Unknown>"} : $error")
|
||||||
|
|
||||||
/** Specifies the cause for notarisation request failure. */
|
/** Specifies the cause for notarisation request failure. */
|
||||||
@CordaSerializable
|
@CordaSerializable
|
||||||
@ -27,7 +27,9 @@ sealed class NotaryError {
|
|||||||
/** Specifies which states have already been consumed in another transaction. */
|
/** Specifies which states have already been consumed in another transaction. */
|
||||||
val consumedStates: Map<StateRef, StateConsumptionDetails>
|
val consumedStates: Map<StateRef, StateConsumptionDetails>
|
||||||
) : NotaryError() {
|
) : NotaryError() {
|
||||||
override fun toString() = "One or more input states have been used in another transaction"
|
override fun toString() = "Conflict notarising transaction $txId. " +
|
||||||
|
"Input states have been used in another transactions, count: ${consumedStates.size}, " +
|
||||||
|
"content: ${consumedStates.asSequence().joinToString(limit = 5) { it.key.toString() + "->" + it.value }}"
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Occurs when time specified in the [TimeWindow] command is outside the allowed tolerance. */
|
/** Occurs when time specified in the [TimeWindow] command is outside the allowed tolerance. */
|
||||||
|
@ -10,6 +10,7 @@ import net.corda.testing.core.SerializationEnvironmentRule
|
|||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
class NotaryExceptionSerializationTest {
|
class NotaryExceptionSerializationTest {
|
||||||
@Rule
|
@Rule
|
||||||
@ -27,5 +28,6 @@ class NotaryExceptionSerializationTest {
|
|||||||
val instanceOnTheOtherSide = instance.serialize().bytes.deserialize<NotaryException>()
|
val instanceOnTheOtherSide = instance.serialize().bytes.deserialize<NotaryException>()
|
||||||
|
|
||||||
assertEquals(instance.error, instanceOnTheOtherSide.error)
|
assertEquals(instance.error, instanceOnTheOtherSide.error)
|
||||||
|
assertTrue(instance.error.toString().contains("->"))
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -52,6 +52,7 @@ open class CashPaymentFlow(
|
|||||||
val anonymousRecipient = txIdentities[recipient] ?: recipient
|
val anonymousRecipient = txIdentities[recipient] ?: recipient
|
||||||
progressTracker.currentStep = GENERATING_TX
|
progressTracker.currentStep = GENERATING_TX
|
||||||
val builder = TransactionBuilder(notary = null)
|
val builder = TransactionBuilder(notary = null)
|
||||||
|
logger.info("Generating spend for: ${builder.lockId}")
|
||||||
// TODO: Have some way of restricting this to states the caller controls
|
// TODO: Have some way of restricting this to states the caller controls
|
||||||
val (spendTX, keysForSigning) = try {
|
val (spendTX, keysForSigning) = try {
|
||||||
Cash.generateSpend(serviceHub,
|
Cash.generateSpend(serviceHub,
|
||||||
@ -65,10 +66,13 @@ open class CashPaymentFlow(
|
|||||||
}
|
}
|
||||||
|
|
||||||
progressTracker.currentStep = SIGNING_TX
|
progressTracker.currentStep = SIGNING_TX
|
||||||
|
logger.info("Signing transaction for: ${spendTX.lockId}")
|
||||||
val tx = serviceHub.signInitialTransaction(spendTX, keysForSigning)
|
val tx = serviceHub.signInitialTransaction(spendTX, keysForSigning)
|
||||||
|
|
||||||
progressTracker.currentStep = FINALISING_TX
|
progressTracker.currentStep = FINALISING_TX
|
||||||
|
logger.info("Finalising transaction for: ${tx.id}")
|
||||||
val notarised = finaliseTx(tx, setOf(recipient), "Unable to notarise spend")
|
val notarised = finaliseTx(tx, setOf(recipient), "Unable to notarise spend")
|
||||||
|
logger.info("Finalised transaction for: ${notarised.id}")
|
||||||
return Result(notarised, anonymousRecipient)
|
return Result(notarised, anonymousRecipient)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user