net.i2p.router.message

## Class HandleGarlicMessageJob

- java.lang.Object
- - net.i2p.router.JobImpl
  - - net.i2p.router.message.HandleGarlicMessageJob

- All Implemented Interfaces:
    Job, GarlicMessageReceiver.CloveReceiver

      public class HandleGarlicMessageJob
      extends JobImpl
      implements GarlicMessageReceiver.CloveReceiver

  Job to handle an inbound GarlicMessage received outside of a tunnel.

  Decrypts the garlic message and processes each contained clove. Local-message cloves are added directly to the inbound message pool, while cloves destined for other routers or tunnels are forwarded accordingly.

  This class handles garlic messages received directly (not down a tunnel), e.g., in floodfill routers receiving network database messages.

  Implements `GarlicMessageReceiver.CloveReceiver` to receive and process individual cloves. Public visibility is necessary for integration with the job queue system.

- - ### Field Summary

    - ### Fields inherited from class net.i2p.router.JobImpl

      `_id`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HandleGarlicMessageJob(RouterContext context, GarlicMessage msg, RouterIdentity from, Hash fromHash, long msgIDBloomXorLocal, long msgIDBloomXorRouter, long msgIDBloomXorTunnel)` Constructs a job to handle an inbound garlic message.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `dropped()` Called when this job has been dropped (e.g.
    `String` | `getName()` Returns a descriptive name for this job.
    `void` | `handleClove(DeliveryInstructions instructions, I2NPMessage data)` Handle each garlic clove based on its delivery instructions.
    `void` | `runJob()` Entry point for the job.

    - ### Methods inherited from class net.i2p.router.JobImpl

      `getContext, getJobId, getMadeReadyOn, getTiming, madeReady, requeue, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### HandleGarlicMessageJob

          public HandleGarlicMessageJob(RouterContext context,
                                        GarlicMessage msg,
                                        RouterIdentity from,
                                        Hash fromHash,
                                        long msgIDBloomXorLocal,
                                        long msgIDBloomXorRouter,
                                        long msgIDBloomXorTunnel)

      Constructs a job to handle an inbound garlic message.
      Parameters:
        `context` - router context providing core services
        `msg` - garlic message to process
        `from` - ignored (sender identity)
        `fromHash` - ignored (sender hash)
        `msgIDBloomXorLocal` - long unique to router/session for XOR with message ID in local inbound messages
        `msgIDBloomXorRouter` - long unique to router/session for XOR with message ID in router-targeted messages
        `msgIDBloomXorTunnel` - long unique to router/session for XOR with message ID in tunnel-targeted messages

  - ### Method Detail

    - #### dropped

          public void dropped()

      Called when this job has been dropped (e.g. due to queue overload). Records an error in message history indicating the message was dropped.
      Specified by:
        `dropped` in interface `Job`
      Overrides:
        `dropped` in class `JobImpl`

    - #### getName

          public String getName()

      Returns a descriptive name for this job.
      Specified by:
        `getName` in interface `Job`
      Returns:
        Name of the job.

    - #### handleClove

          public void handleClove(DeliveryInstructions instructions,
                                  I2NPMessage data)

      Handle each garlic clove based on its delivery instructions.

      Local delivery cloves are added to the inbound message pool with a XOR mask for the message ID. Router delivery cloves are either queued locally or forwarded directly. Tunnel delivery cloves are wrapped in a TunnelGatewayMessage and forwarded.

      Specified by:
        `handleClove` in interface `GarlicMessageReceiver.CloveReceiver`
      Parameters:
        `instructions` - Delivery instructions specifying the target for this clove.
        `data` - The message contained in the clove.

    - #### runJob

          public void runJob()

      Entry point for the job. Creates an instance of GarlicMessageReceiver configured to use this job as the clove receiver, then processes the garlic message.
      Specified by:
        `runJob` in interface `Job`