当我们更改字段或为Corda输入状态生成新的输出状态时,有什么方法可以将通知从保管库发送到API。在状态发生变化时将状态发送给不同方的状态下工作。因此,当发生更改时,我想开发一个API,将通知发送到前端。我读过我们可以在corda中使用vaultTrackBy。 Java是否为此提供任何实现。
是。您可以使用vaultTrack功能获取Vault更新。
final NetworkHostAndPort nodeAddress = NetworkHostAndPort.parse(args[0]);
final CordaRPCClient client = new CordaRPCClient(nodeAddress, CordaRPCClientConfiguration.DEFAULT);
// Can be amended in the com.example.Main file.
final CordaRPCOps proxy = client.start("user1", "test").getProxy();
// Grab all existing and future IOU states in the vault.
final DataFeed<Vault.Page<IOUState>, Vault.Update<IOUState>> dataFeed = proxy.vaultTrack(IOUState.class);
final Vault.Page<IOUState> snapshot = dataFeed.getSnapshot();
final Observable<Vault.Update<IOUState>> updates = dataFeed.getUpdates();
// Log the 'placed' IOUs and listen for new ones.
snapshot.getStates().forEach(ExampleClientRPC::logState);
updates.toBlocking().subscribe(update -> update.getProduced().forEach(state -> log.info("State: "+state)));