Hubert - Distributed Infrastructure for Secure Multiparty Transactions - v1.0.0-alpha.20
    Preparing search index...

    Class HybridKv

    Hybrid storage layer combining Mainline DHT and IPFS.

    Automatically optimizes storage based on envelope size:

    • Small envelopes (≤1000 bytes): Stored directly in DHT
    • Large envelopes (>1000 bytes): Reference in DHT → actual envelope in IPFS

    This provides the best of both worlds:

    • Fast lookups for small messages via DHT
    • Large capacity for big messages via IPFS
    • Transparent indirection handled automatically

    Port of struct HybridKv from hybrid/kv.rs lines 59-63.

    Requirements

    const store = await HybridKv.create("http://127.0.0.1:5001");

    // Small envelope → DHT only
    const arid1 = ARID.new();
    const small = Envelope.new("Small message");
    await store.put(arid1, small);

    // Large envelope → DHT reference + IPFS
    const arid2 = ARID.new();
    const large = Envelope.new("x".repeat(2000));
    await store.put(arid2, large);

    // Get works the same for both
    const retrieved1 = await store.get(arid1);
    const retrieved2 = await store.get(arid2);

    Implements

    Index

    Methods

    • Create a new Hybrid KV store with default settings.

      Port of HybridKv::new() from hybrid/kv.rs lines 75-84.

      Parameters

      Returns Promise<HybridKv>

    • Set custom DHT size limit (default: 1000 bytes).

      Envelopes larger than this will use IPFS indirection.

      Port of HybridKv::with_dht_size_limit() from hybrid/kv.rs lines 89-92.

      Parameters

      • limit: number

      Returns this

    • Set whether to pin content in IPFS (default: false).

      Only affects envelopes stored in IPFS (when larger than DHT limit).

      Port of HybridKv::with_pin_content() from hybrid/kv.rs lines 97-100.

      Parameters

      • pin: boolean

      Returns this

    • Store an envelope at the given ARID.

      Port of KvStore::put() implementation from hybrid/kv.rs lines 109-168.

      Parameters

      • arid: ARID
      • envelope: Envelope
      • OptionalttlSeconds: number
      • Optionalverbose: boolean

      Returns Promise<string>

    • Retrieve an envelope for the given ARID.

      Port of KvStore::get() implementation from hybrid/kv.rs lines 171-230.

      Parameters

      • arid: ARID
      • OptionaltimeoutSeconds: number
      • Optionalverbose: boolean

      Returns Promise<Envelope | null>

    • Check if an envelope exists at the given ARID.

      Port of KvStore::exists() implementation from hybrid/kv.rs lines 254-257.

      Parameters

      • arid: ARID

      Returns Promise<boolean>

    • Destroy the hybrid store and release resources.

      Returns Promise<void>