Options
All
  • Public
  • Public/Protected
  • All
Menu

@ndn/repo-external

This package is part of NDNts, Named Data Networking libraries for the modern web.

This package allows inserting and deleting Data in ndn-python-repo, version 0.2a5. PyRepoClient type is a client for ndn-python-repo protocol. PyRepoStore type implements a subset of DataStore interfaces defined in @ndn/repo-api package.

import { PyRepoStore } from "@ndn/repo-external";

import { Forwarder } from "@ndn/fw";
import { L3Face } from "@ndn/l3face";
import { enableNfdPrefixReg } from "@ndn/nfdmgmt";
import { UnixTransport } from "@ndn/node-transport";
import { Data, digestSigning, Name } from "@ndn/packet";

(async () => {
  const repoPrefix = process.env.DEMO_PYREPO_PREFIX;
  if (!repoPrefix) {
    console.log(`
    To run @ndn/repo-external demo, set the following environment variables:
    DEMO_PYREPO_PREFIX= command prefix of ndn-python-repo
    `);
    return;
  }
  const dataPrefix = new Name(`/NDNts-repo-external/${Math.floor(Math.random() * 99999999)}`);

  const face = Forwarder.getDefault().addFace(new L3Face(await UnixTransport.connect("/run/nfd.sock")));
  face.addRoute(new Name());
  enableNfdPrefixReg(face);

  const store = new PyRepoStore({
    repoPrefix: new Name(repoPrefix),
  });

  const packets: Data[] = [];
  for (let i = 0; i < 256; ++i) {
    const data = new Data(dataPrefix.append(`${i}`));
    data.freshnessPeriod = 1;
    await digestSigning.sign(data);
    packets.push(data);
  }

  console.log(`Inserting ${packets.length} packets under ${dataPrefix} to ${repoPrefix}`);
  try {
    await store.insert(...packets);
  } finally {
    await store.close();
    face.close();
  }
})().then(console.log, console.error);

Index

References

PrpsPublisher

Re-exports PrpsPublisher

PrpsPublisher

Re-exports PrpsPublisher

PrpsSubscriber

Re-exports PrpsSubscriber

PrpsSubscriber

Re-exports PrpsSubscriber

PyRepoClient

Re-exports PyRepoClient

PyRepoClient

Re-exports PyRepoClient

PyRepoStore

Re-exports PyRepoStore

PyRepoStore

Re-exports PyRepoStore

Type aliases

Item

Variables

Const CheckVerb

CheckVerb: Component = Component.from("check")

Const DeleteVerb

DeleteVerb: Component = Component.from("delete")

Const EVD

EVD: EvDecoder<NotifyParams> = new EvDecoder<NotifyParams>("NotifyParams").add(l3TT.Name, (t, { decoder }) => t.publisher = decoder.decode(Name)).add(TT.NotifyNonce, (t, { value }) => t.nonce = value).add(TT.PublisherFwHint, (t, { vd }) => t.publisherFwHint = vd.decode(Name))

Const InsertVerb

InsertVerb: Component = Component.from("insert")

Const MsgSuffix

MsgSuffix: Component = Component.from("msg")

Const NotifySuffix

NotifySuffix: Component = Component.from("notify")

Object literals

Const TT

TT: object

NotifyNonce

NotifyNonce: number = 128

PublisherFwHint

PublisherFwHint: number = 211

Const TT

TT: object

CheckPrefix

CheckPrefix: number = 213

DeleteNum

DeleteNum: number = 210

EndBlockId

EndBlockId: number = 205

ForwardingHint

ForwardingHint: number = 211

InsertNum

InsertNum: number = 209

ProcessId

ProcessId: number = 206

RegisterPrefix

RegisterPrefix: number = 212

StartBlockId

StartBlockId: number = 204

StatusCode

StatusCode: number = 208

Legend

  • Namespace
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Type alias
  • Type alias with type parameter
  • Interface
  • Interface with type parameter
  • Class
  • Class with type parameter
  • Enumeration

Generated using TypeDoc