mirror of
https://github.com/corda/corda.git
synced 2025-06-10 19:31:46 +00:00
ENT-1975 Remove mutex and SQLException handling around perfcordapp coin selection to rely on flow hospital.
This commit is contained in:
parent
34a9a7aa05
commit
af1c3289ab
@ -59,9 +59,6 @@ abstract class AbstractCashSelection(private val maxRetries: Int = 8, private va
|
|||||||
private val log = contextLogger()
|
private val log = contextLogger()
|
||||||
}
|
}
|
||||||
|
|
||||||
// coin selection retry loop counter, sleep (msecs) and lock for selecting states
|
|
||||||
private val spendLock: ReentrantLock = ReentrantLock()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upon dynamically loading configured Cash Selection algorithms declared in META-INF/services
|
* Upon dynamically loading configured Cash Selection algorithms declared in META-INF/services
|
||||||
* this method determines whether the loaded implementation is compatible and usable with the currently
|
* this method determines whether the loaded implementation is compatible and usable with the currently
|
||||||
@ -131,7 +128,6 @@ abstract class AbstractCashSelection(private val maxRetries: Int = 8, private va
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun attemptSpend(services: ServiceHub, amount: Amount<Currency>, lockId: UUID, notary: Party?, onlyFromIssuerParties: Set<AbstractParty>, withIssuerRefs: Set<OpaqueBytes>, stateAndRefs: MutableList<StateAndRef<Cash.State>>): Boolean {
|
private fun attemptSpend(services: ServiceHub, amount: Amount<Currency>, lockId: UUID, notary: Party?, onlyFromIssuerParties: Set<AbstractParty>, withIssuerRefs: Set<OpaqueBytes>, stateAndRefs: MutableList<StateAndRef<Cash.State>>): Boolean {
|
||||||
spendLock.withLock {
|
|
||||||
val connection = services.jdbcSession()
|
val connection = services.jdbcSession()
|
||||||
try {
|
try {
|
||||||
// we select spendable states irrespective of lock but prioritised by unlocked ones (Eg. null)
|
// we select spendable states irrespective of lock but prioritised by unlocked ones (Eg. null)
|
||||||
@ -171,15 +167,10 @@ abstract class AbstractCashSelection(private val maxRetries: Int = 8, private va
|
|||||||
}
|
}
|
||||||
|
|
||||||
// retry as more states may become available
|
// retry as more states may become available
|
||||||
} catch (e: SQLException) {
|
|
||||||
log.error("""Failed retrieving unconsumed states for: amount [$amount], onlyFromIssuerParties [$onlyFromIssuerParties], notary [$notary], lockId [$lockId]
|
|
||||||
$e.
|
|
||||||
""")
|
|
||||||
} catch (e: StatesNotAvailableException) { // Should never happen with single threaded state machine
|
} catch (e: StatesNotAvailableException) { // Should never happen with single threaded state machine
|
||||||
log.warn(e.message)
|
log.warn(e.message)
|
||||||
// retry only if there are locked states that may become available again (or consumed with change)
|
// retry only if there are locked states that may become available again (or consumed with change)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user