Event Listeners
When building a blueprint, your application may require to listen to events. Events can be of any type, and handling those events is entirely up to your discretion.
In general, when defining your job, you must register any event listeners and provide a context as such:
#[job(
id = 0,
params(x),
result(_),
event_listener(TangleEventListener, MyEventListener1, MyEventListener2, ...), // <-- Register all event listeners here
verifier(evm = "MyVerifier")
)]
pub fn hello_event_listener(
x: u64,
context: MyContext, // <-- The context type must be the first additional parameter
env: GadgetConfiguration<parking_lot::RawRwLock>,
) -> Result<u64, Infallible> {
Ok(x.saturating_pow(2u32))
}
In order to understand how to build an event listener, begin with a custom implementation here