我正在尝试从PartyA查询其他节点(PartyB)的存储库,其中的流应该由PartyA的RPC发起。如果PartyB同意共享结果,PartyA应该能够看到结果。有可能吗?
发布于 2018-04-24 15:08:25
不是的。节点操作员只能查询自己节点的保管库。
但是,如果PartyB愿意与PartyA共享其vault的内容,您可以编写一个流对,允许PartyA从PartyB的vault请求状态。
例如,如果您想请求一个具有特定ID的LinearState
,您可以这样写:
@InitiatingFlow
@StartableByRPC
public static class RequestStateFlow extends FlowLogic<StateAndRef> {
private final UniqueIdentifier stateLinearId;
private final Party otherParty;
public RequestStateFlow(UniqueIdentifier stateLinearId, Party otherParty) {
this.stateLinearId = stateLinearId;
this.otherParty = otherParty;
}
@Suspendable
@Override
public StateAndRef call() throws FlowException {
FlowSession session = initiateFlow(otherParty);
return session.sendAndReceive(StateAndRef.class, stateLinearId).unwrap(it -> it);
}
}
@InitiatedBy(RequestStateFlow.class)
public static class SendStateFlow extends FlowLogic<Void> {
private final FlowSession otherPartySession;
public SendStateFlow(FlowSession otherPartySession) {
this.otherPartySession = otherPartySession;
}
@Suspendable
@Override
public Void call() throws FlowException {
UniqueIdentifier stateLinearId = otherPartySession.receive(UniqueIdentifier.class).unwrap(it -> it);
QueryCriteria.LinearStateQueryCriteria criteria = new QueryCriteria.LinearStateQueryCriteria(
null,
ImmutableList.of(stateLinearId),
Vault.StateStatus.UNCONSUMED,
null);
Vault.Page<LinearState> results = getServiceHub().getVaultService().queryBy(LinearState.class, criteria);
StateAndRef state = results.getStates().get(0);
otherPartySession.send(state);
return null;
}
}
https://stackoverflow.com/questions/49856040
复制相似问题