private void complete(Node node) { synchronized (node.getCallbackService()) { // full environment Binder fullEnvironment = node.getFullEnvironment(environmentId); FollowerContract follower = (FollowerContract) fullEnvironment.get("follower"); NMutableEnvironment environment = (NMutableEnvironment) fullEnvironment.get("environment"); // complete event follower.onContractSubscriptionEvent(new ContractSubscription.CompletedEvent() { @Override public MutableEnvironment getEnvironment() { return environment; } }); environment.save(); } }
private void fail(Node node) { synchronized (node.getCallbackService()) { // full environment Binder fullEnvironment = node.getFullEnvironment(environmentId); FollowerContract follower = (FollowerContract) fullEnvironment.get("follower"); NMutableEnvironment environment = (NMutableEnvironment) fullEnvironment.get("environment"); // fail event follower.onContractSubscriptionEvent(new ContractSubscription.FailedEvent() { @Override public MutableEnvironment getEnvironment() { return environment; } }); environment.save(); } }
private void spent(Node node) { synchronized (node.getCallbackService()) { // full environment Binder fullEnvironment = node.getFullEnvironment(environmentId); FollowerContract follower = (FollowerContract) fullEnvironment.get("follower"); NMutableEnvironment environment = (NMutableEnvironment) fullEnvironment.get("environment"); // fail event follower.onContractSubscriptionEvent(new ContractSubscription.SpentEvent() { @Override public MutableEnvironment getEnvironment() { return environment; } }); environment.save(); } }
private void complete() { synchronized (callbackService) { // full environment Binder fullEnvironment = node.getFullEnvironment(environmentId); NSmartContract follower = (NSmartContract) fullEnvironment.get("follower"); NMutableEnvironment environment = (NMutableEnvironment) fullEnvironment.get("environment"); callbackProcessors.remove(id); node.report(DatagramAdapter.VerboseLevel.DETAILED, "CallbackProcessor.complete: Removed callback ", id.toBase64String()); follower.onContractSubscriptionEvent(new ContractSubscription.CompletedEvent() { @Override public MutableEnvironment getEnvironment() { return environment; } }); environment.save(); } // save new callback state in DB record ledger.updateFollowerCallbackState(id, FollowerCallbackState.COMPLETED); node.report(DatagramAdapter.VerboseLevel.BASE, "Completed callback ", id.toBase64String()); stop(); }
private void fail() { synchronized (callbackService) { // full environment Binder fullEnvironment = node.getFullEnvironment(environmentId); NSmartContract follower = (NSmartContract) fullEnvironment.get("follower"); NMutableEnvironment environment = (NMutableEnvironment) fullEnvironment.get("environment"); callbackProcessors.remove(id); node.report(DatagramAdapter.VerboseLevel.DETAILED, "CallbackProcessor.fail: Removed callback ", id.toBase64String()); follower.onContractSubscriptionEvent(new ContractSubscription.FailedEvent() { @Override public MutableEnvironment getEnvironment() { return environment; } }); environment.save(); } // save new callback state in DB record ledger.updateFollowerCallbackState(id, FollowerCallbackState.EXPIRED); node.report(DatagramAdapter.VerboseLevel.BASE, "Failed callback ", id.toBase64String()); stop(); }