Tangle Job Call Listeners
Tangle Job Call Listeners are a powerful feature in the Gadget SDK that allow your blueprint to react to job calls on the Tangle network. These listeners leverage Rust's async capabilities and the tokio
runtime to efficiently handle incoming job requests.
Overview
Tangle Job Call Listeners enable your blueprint to:
- Listen for specific job calls on the Tangle network
- Execute custom logic in response to job calls
- Process and validate job parameters
Tangle Job Call Listeners are particularly useful for tasks such as:
- Executing on-chain operations based on job requests
- Validating and processing data submitted through jobs
- Triggering off-chain actions in response to on-chain events
- Implementing complex business logic that integrates with the Tangle network
These listeners form a crucial part of Tangle's native job system, allowing blueprints to interact seamlessly with the broader Tangle ecosystem and respond to network events in real-time.
TangleEventListener
The TangleEventListener
is a type that listens to the Tangle network for events. This is a required type if you expect your application to use the tangle network to listen to jobs.
The TangleEventListener
is already implemented and ready to use. Simply register it in the job
macro, and your application
will automatically work with the Tangle network.
/// Returns x^2 saturating to [`u64::MAX`] if overflow occurs.
#[job(
id = 0,
params(x),
result(_),
event_listener(TangleEventListener),
verifier(evm = "IncredibleSquaringBlueprint")
)]
pub fn xsquare(
x: u64,
) -> Result<u64, Infallible> {
Ok(x.saturating_pow(2u32))
}