mirror of
https://github.com/corda/corda.git
synced 2024-12-22 06:17:55 +00:00
Minor persistent uniqueness provider tweak
This commit is contained in:
parent
789bb2bb9d
commit
422a766c1a
@ -333,12 +333,11 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
|
||||
}
|
||||
|
||||
open protected fun makeNotaryService(type: ServiceType): NotaryService {
|
||||
val uniquenessProvider = makeUniquenessProvider()
|
||||
val timestampChecker = TimestampChecker(platformClock, 30.seconds)
|
||||
|
||||
return when (type) {
|
||||
SimpleNotaryService.Type -> SimpleNotaryService(smm, net, timestampChecker, uniquenessProvider, services.networkMapCache)
|
||||
ValidatingNotaryService.Type -> ValidatingNotaryService(smm, net, timestampChecker, uniquenessProvider, services.networkMapCache)
|
||||
SimpleNotaryService.Type -> SimpleNotaryService(smm, net, timestampChecker, uniquenessProvider!!, services.networkMapCache)
|
||||
ValidatingNotaryService.Type -> ValidatingNotaryService(smm, net, timestampChecker, uniquenessProvider!!, services.networkMapCache)
|
||||
else -> {
|
||||
throw IllegalArgumentException("Notary type ${type.id} is not handled by makeNotaryService.")
|
||||
}
|
||||
|
@ -7,16 +7,18 @@ import com.r3corda.core.crypto.SecureHash
|
||||
import com.r3corda.core.node.services.UniquenessException
|
||||
import com.r3corda.core.node.services.UniquenessProvider
|
||||
import com.r3corda.core.serialization.SingletonSerializeAsToken
|
||||
import com.r3corda.core.utilities.loggerFor
|
||||
import com.r3corda.node.utilities.JDBCHashMap
|
||||
import com.r3corda.node.utilities.databaseTransaction
|
||||
import java.util.*
|
||||
import javax.annotation.concurrent.ThreadSafe
|
||||
|
||||
/** A a RDBMS backed Uniqueness provider */
|
||||
/** A RDBMS backed Uniqueness provider */
|
||||
@ThreadSafe
|
||||
class PersistentUniquenessProvider() : UniquenessProvider, SingletonSerializeAsToken() {
|
||||
companion object {
|
||||
private val TABLE_NAME = "notary_commit_log"
|
||||
private val log = loggerFor<PersistentUniquenessProvider>()
|
||||
}
|
||||
|
||||
/**
|
||||
@ -37,11 +39,13 @@ class PersistentUniquenessProvider() : UniquenessProvider, SingletonSerializeAsT
|
||||
if (consumingTx != null) conflictingStates[inputState] = consumingTx
|
||||
}
|
||||
if (conflictingStates.isNotEmpty()) {
|
||||
log.debug("Failure, input states already committed: ${conflictingStates.keys.toString()}")
|
||||
UniquenessProvider.Conflict(conflictingStates)
|
||||
} else {
|
||||
states.forEachIndexed { i, stateRef ->
|
||||
put(stateRef, UniquenessProvider.ConsumingTx(txId, i, callerIdentity))
|
||||
}
|
||||
log.debug("Successfully committed all input states: $states")
|
||||
null
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user