交易建立期间输入/输出状态的数量是否有限制?

时间:2018-08-10 07:30:26

标签: corda

在带postgres 9.6的Corda开源3.2上。我在交易中有300个义务状态,这些义务状态必须自动转换为react-native-maps AND 现金状态,以作为消除这些义务的输入。

SETTLED期间出现分页错误。交易中可以包含多少个状态?

下方的Stacktrace

[ERROR] 2018-08-10T06:40:38,702Z [Node thread-1] flow.[a80ddfb6-628e-4194-98ef-77261512b6fb].call - Error during mutedTry  {}
net.corda.core.node.services.VaultQueryException: Please specify a `PageSpecification` as there are more results [201] than the default page size [200]
    at net.corda.node.services.vault.NodeVaultService._queryBy(NodeVaultService.kt:426) ~[corda-node-3.2.1847-corda.jar:?]
    at net.corda.node.services.vault.NodeVaultService.loadStates(NodeVaultService.kt:546) ~[corda-node-3.2.1847-corda.jar:?]
    at net.corda.node.services.vault.NodeVaultService.access$loadStates(NodeVaultService.kt:49) ~[corda-node-3.2.1847-corda.jar:?]
    at net.corda.node.services.vault.NodeVaultService$makeUpdates$1.invoke(NodeVaultService.kt:143) ~[corda-node-3.2.1847-corda.jar:?]
    at net.corda.node.services.vault.NodeVaultService.makeUpdates(NodeVaultService.kt:188) ~[corda-node-3.2.1847-corda.jar:?]
    at net.corda.node.services.vault.NodeVaultService.access$makeUpdates(NodeVaultService.kt:49) ~[corda-node-3.2.1847-corda.jar:?]
    at net.corda.node.services.vault.NodeVaultService$notifyAll$1.invoke(NodeVaultService.kt:119) ~[corda-node-3.2.1847-corda.jar:?]
    at net.corda.node.services.vault.NodeVaultService.notifyAll(NodeVaultService.kt:130) ~[corda-node-3.2.1847-corda.jar:?]
    at net.corda.node.services.api.ServiceHubInternal$DefaultImpls.recordTransactions(ServiceHubInternal.kt:118) ~[corda-node-3.2.1847-corda.jar:?]
    at net.corda.node.internal.AbstractNode$ServiceHubInternalImpl$recordTransactions$1.invoke(AbstractNode.kt:857) ~[corda-node-3.2.1847-corda.jar:?]
    at net.corda.node.internal.AbstractNode$ServiceHubInternalImpl$recordTransactions$1.invoke(AbstractNode.kt:818) ~[corda-node-3.2.1847-corda.jar:?]
    at net.corda.nodeapi.internal.persistence.CordaPersistence.transaction(CordaPersistence.kt:136) ~[corda-node-api-3.2.1847-corda.jar:?]
    at net.corda.nodeapi.internal.persistence.CordaPersistence.transaction(CordaPersistence.kt:124) ~[corda-node-api-3.2.1847-corda.jar:?]
    at net.corda.nodeapi.internal.persistence.CordaPersistence.transaction(CordaPersistence.kt:131) ~[corda-node-api-3.2.1847-corda.jar:?]
    at net.corda.node.internal.AbstractNode$ServiceHubInternalImpl.recordTransactions(AbstractNode.kt:856) ~[corda-node-3.2.1847-corda.jar:?]
    at net.corda.core.node.ServiceHub$DefaultImpls.recordTransactions(ServiceHub.kt:201) ~[corda-core-3.2.1847-corda.jar:?]
    at net.corda.node.services.api.ServiceHubInternal$DefaultImpls.recordTransactions(ServiceHubInternal.kt) ~[corda-node-3.2.1847-corda.jar:?]
    at net.corda.node.internal.AbstractNode$ServiceHubInternalImpl.recordTransactions(AbstractNode.kt:818) ~[corda-node-3.2.1847-corda.jar:?]
    at net.corda.core.node.ServiceHub$DefaultImpls.recordTransactions(ServiceHub.kt:193) ~[corda-core-3.2.1847-corda.jar:?]
    at net.corda.node.services.api.ServiceHubInternal$DefaultImpls.recordTransactions(ServiceHubInternal.kt) ~[corda-node-3.2.1847-corda.jar:?]
    at net.corda.node.internal.AbstractNode$ServiceHubInternalImpl.recordTransactions(AbstractNode.kt:818) ~[corda-node-3.2.1847-corda.jar:?]
    at net.corda.core.flows.FinalityFlow.notariseAndRecord(FinalityFlow.kt:78) ~[corda-core-3.2.1847-corda.jar:?]
    at net.corda.core.flows.FinalityFlow.call(FinalityFlow.kt:56) ~[corda-core-3.2.1847-corda.jar:?]
    at net.corda.core.flows.FinalityFlow.call(FinalityFlow.kt:28) ~[corda-core-3.2.1847-corda.jar:?]
    at net.corda.core.flows.FlowLogic.subFlow(FlowLogic.kt:290) ~[corda-core-3.2.1847-corda.jar:?]
    at example.template.flows.SettleOblgiations$Initiator.call(SettleOblgiations.kt:105) ~[obligation-1.0.jar:?]
    at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:96) [corda-node-3.2.1847-corda.jar:?]
    at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:44) [corda-node-3.2.1847-corda.jar:?]
    at co.paralleluniverse.fibers.Fiber.run1(Fiber.java:1092) [quasar-core-0.7.9-jdk8.jar:0.7.9]
    at co.paralleluniverse.fibers.Fiber.exec(Fiber.java:788) [quasar-core-0.7.9-jdk8.jar:0.7.9]
    at co.paralleluniverse.fibers.RunnableFiberTask.doExec(RunnableFiberTask.java:100) [quasar-core-0.7.9-jdk8.jar:0.7.9]
    at co.paralleluniverse.fibers.RunnableFiberTask.run(RunnableFiberTask.java:91) [quasar-core-0.7.9-jdk8.jar:0.7.9]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_171]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_171]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_171]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_171]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_171]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_171]
    at net.corda.node.utilities.AffinityExecutor$ServiceAffinityExecutor$1$thread$1.run(AffinityExecutor.kt:62) [corda-node-3.2.1847-corda.jar:?]

2 个答案:

答案 0 :(得分:0)

通常,如果执行保管库查询返回200多个结果,则需要提供PageSpecification来定义如何返回结果。这是为了防止在返回太多结果时发生内存溢出错误。这是使用PageSpecification进行保管库查询的示例:

val vaultSnapshot = serviceHub.vaultService.queryBy<ContractState>(
    criteria = VaultQueryCriteria(UNCONSUMED),
    paging = PageSpecification(DEFAULT_PAGE_NUM, 200))

FinalityFlow调出到NodeVaultService.loadStates,这是引发错误的地方。从Corda 3.2开始,NodeVaultService.loadStates并没有采取任何措施阻止它一次请求200个以上的结果,从而引发了分页错误。该问题已在master中修复,该修复将包含在Corda 3.3 / Corda 4中,如下所示:

private fun loadStates(refs: Collection<StateRef>): Collection<StateAndRef<ContractState>> {
    val states = mutableListOf<StateAndRef<ContractState>>()
    if (refs.isNotEmpty()) {
        val refsList = refs.toList()
        val pageSize = PageSpecification().pageSize
        (0..(refsList.size - 1) / pageSize).forEach {
            val offset = it * pageSize
            val limit = minOf(offset + pageSize, refsList.size)
            val page = queryBy<ContractState>(QueryCriteria.VaultQueryCriteria(stateRefs = refsList.subList(offset, limit))).states
            states.addAll(page)
        }
    }
    return states
}

答案 1 :(得分:0)

感谢提出这个问题。 自5月以来,它确实已在master上修复,并将包含在下一个OS 3.3版本中。 参见https://github.com/corda/corda/pull/3788