@libp2p/bootstrap
Advanced tools
Comparing version
@@ -1,4 +0,3 @@ | ||
/// <reference types="node" /> | ||
import { EventEmitter } from 'events'; | ||
import type PeerDiscovery from '@libp2p/interfaces/peer-discovery'; | ||
import { EventEmitter } from '@libp2p/interfaces'; | ||
import type { PeerDiscovery, PeerDiscoveryEvents } from '@libp2p/interfaces/peer-discovery'; | ||
export interface BootstrapOptions { | ||
@@ -17,3 +16,3 @@ /** | ||
*/ | ||
export declare class Bootstrap extends EventEmitter implements PeerDiscovery { | ||
export declare class Bootstrap extends EventEmitter<PeerDiscoveryEvents> implements PeerDiscovery { | ||
static tag: string; | ||
@@ -20,0 +19,0 @@ private timer?; |
@@ -1,9 +0,7 @@ | ||
import { PeerId } from '@libp2p/peer-id'; | ||
import { Multiaddr } from '@multiformats/multiaddr'; | ||
import { P2P } from '@multiformats/mafmt'; | ||
import { EventEmitter } from 'events'; | ||
import debug from 'debug'; | ||
const log = Object.assign(debug('libp2p:bootstrap'), { | ||
error: debug('libp2p:bootstrap:error') | ||
}); | ||
import { CustomEvent, EventEmitter } from '@libp2p/interfaces'; | ||
import { logger } from '@libp2p/logger'; | ||
import { peerIdFromString } from '@libp2p/peer-id'; | ||
const log = logger('libp2p:bootstrap'); | ||
/** | ||
@@ -32,3 +30,3 @@ * Emits 'peer' events on a regular interval for each peer in the provided list. | ||
const peerData = { | ||
id: PeerId.fromString(peerIdStr), | ||
id: peerIdFromString(peerIdStr), | ||
multiaddrs: [ma], | ||
@@ -62,3 +60,3 @@ protocols: [] | ||
this.list.forEach((peerData) => { | ||
this.emit('peer', peerData); | ||
this.dispatchEvent(new CustomEvent('peer', { detail: peerData })); | ||
}); | ||
@@ -65,0 +63,0 @@ } |
{ | ||
"name": "@libp2p/bootstrap", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Node.js IPFS Implementation of the railing process of a Node through a bootstrap peer list", | ||
@@ -136,13 +136,12 @@ "license": "Apache-2.0 OR MIT", | ||
"dependencies": { | ||
"@libp2p/peer-id": "^1.0.4", | ||
"@libp2p/logger": "^1.1.2", | ||
"@libp2p/peer-id": "^1.1.8", | ||
"@multiformats/mafmt": "^11.0.2", | ||
"@multiformats/multiaddr": "^10.1.2", | ||
"debug": "^4.3.1" | ||
"@multiformats/multiaddr": "^10.1.7" | ||
}, | ||
"devDependencies": { | ||
"@libp2p/interface-compliance-tests": "^1.0.8", | ||
"@libp2p/interfaces": "^1.1.1", | ||
"@types/debug": "^4.1.5", | ||
"@libp2p/interface-compliance-tests": "^1.1.16", | ||
"@libp2p/interfaces": "^1.3.14", | ||
"aegir": "^36.1.3" | ||
} | ||
} |
@@ -1,12 +0,10 @@ | ||
import { PeerId } from '@libp2p/peer-id' | ||
import { Multiaddr } from '@multiformats/multiaddr' | ||
import { P2P } from '@multiformats/mafmt' | ||
import { EventEmitter } from 'events' | ||
import debug from 'debug' | ||
import type PeerDiscovery from '@libp2p/interfaces/peer-discovery' | ||
import { CustomEvent, EventEmitter } from '@libp2p/interfaces' | ||
import { logger } from '@libp2p/logger' | ||
import type { PeerDiscovery, PeerDiscoveryEvents } from '@libp2p/interfaces/peer-discovery' | ||
import type { PeerData } from '@libp2p/interfaces/peer-data' | ||
import { peerIdFromString } from '@libp2p/peer-id' | ||
const log = Object.assign(debug('libp2p:bootstrap'), { | ||
error: debug('libp2p:bootstrap:error') | ||
}) | ||
const log = logger('libp2p:bootstrap') | ||
@@ -28,6 +26,6 @@ export interface BootstrapOptions { | ||
*/ | ||
export class Bootstrap extends EventEmitter implements PeerDiscovery { | ||
export class Bootstrap extends EventEmitter<PeerDiscoveryEvents> implements PeerDiscovery { | ||
static tag = 'bootstrap' | ||
private timer?: NodeJS.Timer | ||
private timer?: ReturnType<typeof setInterval> | ||
private readonly list: PeerData[] | ||
@@ -60,3 +58,3 @@ private readonly interval: number | ||
const peerData: PeerData = { | ||
id: PeerId.fromString(peerIdStr), | ||
id: peerIdFromString(peerIdStr), | ||
multiaddrs: [ma], | ||
@@ -96,3 +94,3 @@ protocols: [] | ||
this.list.forEach((peerData) => { | ||
this.emit('peer', peerData) | ||
this.dispatchEvent(new CustomEvent<PeerData>('peer', { detail: peerData })) | ||
}) | ||
@@ -99,0 +97,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
15683
1.02%3
-25%194
-2.51%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
Updated