forked from mpetrunic/js-libp2p-interfaces
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
39 lines (31 loc) · 823 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import type { PeerId } from '../peer-id'
import type { Connection } from '../connection'
export interface onConnectHandler { (peerId: PeerId, conn: Connection): void }
export interface onDisconnectHandler { (peerId: PeerId, conn?: Connection): void }
export interface Handlers {
onConnect?: onConnectHandler
onDisconnect?: onDisconnectHandler
}
export interface TopologyOptions {
/**
* minimum needed connections
*/
min?: number
/**
* maximum needed connections
*/
max?: number
handlers: Handlers
}
export interface Topology {
min: number
max: number
peers: Set<string>
disconnect: (id: PeerId) => void
}
export interface MulticodecTopologyOptions extends TopologyOptions {
multicodecs: string[]
}
export interface MulticodecTopology extends Topology {
multicodecs: string[]
}