hyperdiscovery

WebJar for hyperdiscovery

Лицензия

Лицензия

ISC
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

hyperdiscovery
Последняя версия

Последняя версия

9.0.2
Дата

Дата

Тип

Тип

jar
Описание

Описание

hyperdiscovery
WebJar for hyperdiscovery
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/datproject/hyperdiscovery

Скачать hyperdiscovery

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/hyperdiscovery/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>hyperdiscovery</artifactId>
    <version>9.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/hyperdiscovery/
implementation 'org.webjars.npm:hyperdiscovery:9.0.2'
// https://jarcasting.com/artifacts/org.webjars.npm/hyperdiscovery/
implementation ("org.webjars.npm:hyperdiscovery:9.0.2")
'org.webjars.npm:hyperdiscovery:jar:9.0.2'
<dependency org="org.webjars.npm" name="hyperdiscovery" rev="9.0.2">
  <artifact name="hyperdiscovery" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='hyperdiscovery', version='9.0.2')
)
libraryDependencies += "org.webjars.npm" % "hyperdiscovery" % "9.0.2"
[org.webjars.npm/hyperdiscovery "9.0.2"]

Зависимости

compile (6)

Идентификатор библиотеки Тип Версия
org.webjars.npm : debug jar [4.1.1,5)
org.webjars.npm : dat-swarm-defaults jar [1.0.2,2)
org.webjars.npm : discovery-swarm jar [5.1.4,6)
org.webjars.npm : dat-encoding jar [5.0.1,6)
org.webjars.npm » mutexify jar [1.2.0,2)
org.webjars.npm : hypercore-protocol jar [6.9.0,7)

Модули Проекта

Данный проект не имеет модулей.

hyperdiscovery

DEPRECATED

This module has been deprecated in favor of hyperswarm/replicator which is compatible with hypercore v8.

Old documentation below

This library is compatible with hypercore<=v7, which is now out of date.

build status

Join the p2p swarm for hypercore and hyperdrive. Uses discovery-swarm under the hood. Also works in web browsers using discovery-swarm-web.

This module only works

npm install hyperdiscovery

Usage

Run the following code in two different places and they will replicate the contents of the given ARCHIVE_KEY.

var hyperdrive = require('hyperdrive')
var hypercore = require('hypercore')
var Discovery = require('hyperdiscovery')

var archive = hyperdrive('./database', 'ARCHIVE_KEY')
var discovery = Discovery(archive)
discovery.on('connection', function (peer, type) {
  console.log('got', peer, type)
  console.log('connected to', discovery.connections, 'peers')
  peer.on('close', function () {
    console.log('peer disconnected')
  })
})

// add another archive/feed later
var feed = hypercore('./feed')
discovery.add(feed) // adds this hypercore feed to the same discovery swarm

Will use discovery-swarm to attempt to connect peers. Uses dat-swarm-defaults for peer introduction defaults on the server side, which can be overwritten (see below).

The module can also create and join a swarm for a hypercore feed:

var hypercore = require('hypercore')
var Discovery = require('hyperdiscovery')

var feed = hypercore('/feed')
var discovery = Discovery(feed)

API

var discovery = Discovery(archive, opts)

Join the p2p swarm for the given feed. The return object, discovery, is an event emitter that will emit a peer event with the peer information when a peer is found.

discovery.add(archive, [opts])

Add an archive/feed to the discovery swarm. Options will be passed to discovery-swarm. If you pass opts.announce as a falsy value you don't announce your port (discover-only mode).

discovery.totalConnections

Get length of the list of total active connections, across all archives and feeds.

discovery.leave(discoveryKey)

Leave discovery for a specific discovery key.

discovery.rejoin(discoveryKey)

Rejoin discovery for a discovery key (*must be added first using discovery.add).

discovery.close()

Exit the swarm, close all replication streams.

Options
  • stream: function, replication stream for connection. Default is archive.replicate({live, upload, download}).
  • upload: bool, upload data to the other peer?
  • download: bool, download data from the other peer?
  • port: port for discovery swarm
  • utp: use utp in discovery swarm
  • tcp: use tcp in discovery swarm
  • bootstrap: [string], WebRTC bootstrap signal servers for web
  • discovery: string, discovery-swarm-stream server for web

Defaults from datland-swarm-defaults can also be overwritten:

  • dns.server: DNS server
  • dns.domain: DNS domain
  • dht.bootstrap: distributed hash table bootstrapping nodes

Debugging

Set DEBUG='*' in the environment to enable debugging output inside discovery-swarm.

See Also

License

ISC

org.webjars.npm

Dat Project

A distributed data community. Dat is a nonprofit-backed data syncronization protocol for peer-to-peer applications

Версии библиотеки

Версия
9.0.2