net.i2p.data

## Class MetaLeaseSet

- java.lang.Object
- - net.i2p.data.DataStructureImpl
  - - net.i2p.data.DatabaseEntry
    - - net.i2p.data.LeaseSet
      - - net.i2p.data.LeaseSet2
        - - net.i2p.data.MetaLeaseSet

- All Implemented Interfaces:
    Serializable, DataStructure

      public class MetaLeaseSet
      extends LeaseSet2

  Implementation of MetaLeaseSet as specified in Proposal 123: New NetDb Entries.

  MetaLeaseSet is a specialized LeaseSet2 that contains references to other LeaseSets rather than direct tunnel endpoints. This enables advanced routing and load balancing strategies.

  Key characteristics of MetaLeaseSet:

  - Contains `MetaLease` objects instead of regular `Lease` objects
  - Does not support encryption keys (throws `UnsupportedOperationException`)
  - References other LeaseSets by hash rather than containing tunnel endpoints directly
  - Supports offline signatures for reduced router load
  - Includes options and statistics support

  Usage: MetaLeaseSets are used for:

  - Load balancing across multiple LeaseSets
  - Geographic or performance-based routing decisions
  - Fallback and redundancy strategies
  - Service discovery and aggregation

  Implementation Status: PRELIMINARY - Subject to change as the proposal evolves

  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from class net.i2p.data.LeaseSet2

      `_expires, _flags, _offlineSignature, _options, _published, _transientExpires, _transientSigningPublicKey`

    - ### Fields inherited from class net.i2p.data.LeaseSet

      `_byteified, _checked, _destination, _encryptionKey, _lastExpiration, _leases, _signingKey, MAX_LEASES`

    - ### Fields inherited from class net.i2p.data.DatabaseEntry

      `_signature, KEY_TYPE_ENCRYPTED_LS2, KEY_TYPE_LEASESET, KEY_TYPE_LS2, KEY_TYPE_META_LS2, KEY_TYPE_ROUTERINFO, KEY_TYPE_SERVICE_LIST, KEY_TYPE_SERVICE_RECORD`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MetaLeaseSet()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addEncryptionKey(PublicKey key)` Add an encryption key.
    `void` | `addLease(Lease lease)` Adds a lease to this leaseset.
    `boolean` | `equals(Object object)`
    `int` | `getType()` Get the type of the data structure.
    `int` | `hashCode()` the destination has enough randomness in it to use it by itself for speed
    `void` | `readBytes(InputStream in)` This does NOT validate the signature
    `void` | `setEncryptionKey(PublicKey key)` Sets the encryption key for this leaseset.
    `int` | `size()` Number of bytes, NOT including signature
    `String` | `toString()`
    `protected void` | `writeBytesWithoutSig(OutputStream out)` Without sig.

    - ### Methods inherited from class net.i2p.data.LeaseSet2

      `encrypt, getBlindedHash, getBytes, getEncryptionKey, getEncryptionKey, getEncryptionKeys, getExpires, getOption, getOptions, getPublished, getReceivedAsPublished, getTransientExpiration, getTransientSigningKey, isBlindedWhenPublished, isCurrent, isOffline, isUnpublished, offlineSign, readHeader, readOfflineBytes, setBlindedHash, setBlindedWhenPublished, setOfflineSignature, setOptions, setPublished, setSigningKey, setUnpublished, sign, verifyOfflineSignature, verifyOfflineSignature, verifySignature, writeBody, writeBytes, writeHeader, writeOfflineBytes`

    - ### Methods inherited from class net.i2p.data.LeaseSet

      `getDate, getDestination, getEarliestLeaseDate, getKeysAndCert, getLatestLeaseDate, getLease, getLeaseCount, getSigningKey, setDestination, setReceivedBy`

    - ### Methods inherited from class net.i2p.data.DatabaseEntry

      `getHash, getReceivedAsReply, getReceivedBy, getRoutingKey, getSignature, getSigningPublicKey, isLeaseSet, isLeaseSet, isRouterInfo, setReceivedAsPublished, setReceivedAsReply, setSignature, validateRoutingKey`

    - ### Methods inherited from class net.i2p.data.DataStructureImpl

      `calculateHash, fromBase64, fromByteArray, read, toBase64, toByteArray`

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

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

- - ### Constructor Detail

    - #### MetaLeaseSet

          public MetaLeaseSet()

  - ### Method Detail

    - #### addEncryptionKey

          public void addEncryptionKey(PublicKey key)

      Description copied from class: `LeaseSet2`
      Add an encryption key. Encryption keys should be added in order of server preference, most-preferred first.
      Overrides:
        `addEncryptionKey` in class `LeaseSet2`
      Throws:
        `UnsupportedOperationException` - always

    - #### addLease

          public void addLease(Lease lease)

      Description copied from class: `LeaseSet`
      Adds a lease to this leaseset.
      Overrides:
        `addLease` in class `LeaseSet2`
      Parameters:
        `lease` - must be a MetaLease
      Throws:
        `IllegalArgumentException` - if not a MetaLease

    - #### equals

          public boolean equals(Object object)

      Overrides:
        `equals` in class `LeaseSet2`

    - #### getType

          public int getType()

      Description copied from class: `DatabaseEntry`
      Get the type of the data structure. This should be faster than instanceof.
      Overrides:
        `getType` in class `LeaseSet2`
      Returns:
        KEY_TYPE_ROUTERINFO or KEY_TYPE_LEASESET or LS2 types

    - #### hashCode

          public int hashCode()

      the destination has enough randomness in it to use it by itself for speed
      Overrides:
        `hashCode` in class `LeaseSet2`

    - #### readBytes

          public void readBytes(InputStream in)
                         throws DataFormatException,
                                IOException

      This does NOT validate the signature
      Specified by:
        `readBytes` in interface `DataStructure`
      Overrides:
        `readBytes` in class `LeaseSet2`
      Parameters:
        `in` - stream to read from
      Throws:
        `IllegalStateException` - if called more than once or Destination already set
        `DataFormatException` - if the data is improperly formatted
        `IOException` - if there was a problem reading the stream

    - #### setEncryptionKey

          public void setEncryptionKey(PublicKey key)

      Description copied from class: `LeaseSet`
      Sets the encryption key for this leaseset.
      Overrides:
        `setEncryptionKey` in class `LeaseSet`
      Throws:
        `UnsupportedOperationException` - always

    - #### size

          public int size()

      Number of bytes, NOT including signature
      Overrides:
        `size` in class `LeaseSet2`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `LeaseSet2`

    - #### writeBytesWithoutSig

          protected void writeBytesWithoutSig(OutputStream out)
                                       throws DataFormatException,
                                              IOException

      Without sig. This does NOT validate the signature
      Overrides:
        `writeBytesWithoutSig` in class `LeaseSet2`
      Throws:
        `DataFormatException`
        `IOException`