:loop
get tx at after @timestamp and store in @txid
if @txid is zero finish
get timestamp for @txid and store in @tx_time
get tx type for @txid and store in @tx_info
if @tx_info != @am_type_subtype goto skip
But this way requires the script to be constantly polling for "triggers" (here am_type_subtype), which will require extra cycles (and hence cost) right? (Or would the extra cost be negligible?)
I was thinking that instead of pausing/sleeping for a predetermined period, during which the script can't execute and can't poll, you could have some mechanism that allow triggers to wake up the script (or at least run a function that checks whether the trigger is something valid for the script to wake up for).