Trigger only activating when message is MHeartbeat?
- Luis_AlmeidaOP
Hello, is it possible to make it so the trigger only activates and processes the rule only if the message received was MHeartbeat?
I have a registeredTemplate that is queried in the rule and this template is constantly being created and altered in the ledger, leading to unnecessary processing on the trigger. As such, I’d like for the trigger to only query the ledger and emitCommands every minute instead.
As far as I understand, this might be possible by altering the updateState?trigger : Trigger () trigger = Trigger { initialize = const () , updateState = \_-> () , rule = triggerRule , registeredTemplates = RegisteredTemplates [ registeredTemplate @Token ] , heartbeat = Some $ minutes 1 } - bernhard
Change your state from
()to something likedata MyTriggerState = MyTriggerState with heartbeatReceived: Bool. Then in the updateState, you set that boolean toTruewhen you receive a heartbeat, and in the rule, you only calltriggerRulewhenheartbeatReceived == Trueand then set it to False again.