A Crux library that allows you to pipe verified Corda transactions into a Crux node, to then query using Crux’s bitemporal Datalog query engine.
Things of interest:
crux-corda
library-
-
crux-corda/src/main/kotlin/crux/corda/CruxCorda.kt
- entry point for the Crux driver, adds extension functions toAppServiceHub
-
crux-corda/src/main/clojure/crux/corda.clj
- the implementation of the Crux driver -
crux-corda-state/src/main/kotlin/crux/corda/state/CruxState.kt
- interface that Corda states should implement to be included in Crux
-
- Example user app
-
-
iou-contract/src/main/kotlin/com/example/contract/IOUState.kt
- example of a Corda state with a Crux mapping@BelongsToContract(IOUContract::class) data class IOUState(val value: Int, val lender: Party, val borrower: Party, override val linearId: UniqueIdentifier = UniqueIdentifier()) : LinearState, QueryableState, CruxState { override val cruxId = linearId.id override val cruxDoc: Map<String, Any> = mapOf( "iou-state/value" to value, "iou-state/lender" to lender.name.toString(), "iou-state/borrower" to borrower.name.toString()) }
-
iou-workflow/src/main/kotlin/com/example/service/CruxService.kt
- example of a CordaService that starts a Crux node@CordaService class CruxService(private val serviceHub: AppServiceHub) : SingletonSerializeAsToken() { val node = serviceHub.startCruxNode { // configure node } }
By default, Crux looks out for Corda states that implement
CruxState
, but you can manually specify this mapping thus:
-
val node = serviceHub.startCruxNode {
withCordaTxLog {
withDocumentMapping { doc ->
// this is the default implementation,
// replace it with your own mapping
if (doc is CruxState) listOf(doc)
else null
}
}
// ...
}
-
iou-workflow/src/test/kotlin/com/example/workflow/IOUFlowTests.kt
- E2E test for the IOU app