This repository has been archived by the owner on Jun 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: event emitter and discovery and routing interfaces (#95)
- Loading branch information
1 parent
27c3871
commit 93ddaa4
Showing
7 changed files
with
31 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
export = ContentRouting; | ||
|
||
import PeerId from 'peer-id' | ||
import Multiaddr from 'multiaddr' | ||
import { Multiaddr } from 'multiaddr' | ||
import CID from 'cids' | ||
|
||
declare class ContentRouting { | ||
constructor (options: Object); | ||
export interface ContentRoutingFactory { | ||
new (options?: any): ContentRouting; | ||
} | ||
|
||
export interface ContentRouting { | ||
provide (cid: CID): Promise<void>; | ||
findProviders (cid: CID, options: Object): AsyncIterable<{ id: PeerId, multiaddrs: Multiaddr[] }>; | ||
} | ||
|
||
export default ContentRouting; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
export = PeerDiscovery; | ||
import { EventEmitter } from 'events'; | ||
|
||
import events from 'events'; | ||
|
||
declare class PeerDiscovery extends events.EventEmitter { | ||
constructor (options: Object); | ||
start (): Promise<void>; | ||
stop (): Promise<void>; | ||
export interface PeerDiscoveryFactory { | ||
new (options?: any): PeerDiscovery; | ||
tag: string; | ||
} | ||
|
||
export interface PeerDiscovery extends EventEmitter { | ||
start(): void|Promise<void>; | ||
stop(): void|Promise<void>; | ||
} | ||
|
||
export default PeerDiscovery; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
export = PeerRouting; | ||
|
||
import PeerId from 'peer-id' | ||
import Multiaddr from 'multiaddr' | ||
import { Multiaddr } from 'multiaddr' | ||
|
||
export interface PeerRoutingFactory { | ||
new (options?: any): PeerRouting; | ||
} | ||
|
||
declare class PeerRouting { | ||
constructor (options?: Object); | ||
export interface PeerRouting { | ||
findPeer (peerId: PeerId, options?: Object): Promise<{ id: PeerId, multiaddrs: Multiaddr[] }>; | ||
getClosestPeers(key: Uint8Array, options?: Object): AsyncIterable<{ id: PeerId, multiaddrs: Multiaddr[] }>; | ||
} | ||
|
||
export default PeerRouting; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export type SelectFn = function (Uint8Array, Uint8Array[]): number | ||
export type ValidateFn = function (Uint8Array, Uint8Array): Promise<void> | ||
export type SelectFn = (key: Uint8Array, records: Uint8Array[]) => number | ||
export type ValidateFn = (a: Uint8Array, b: Uint8Array) => Promise<void> | ||
|
||
export type DhtSelectors = { [key: string]: SelectFn } | ||
export type DhtValidators = { [key: string]: { func: ValidateFn } } |