1
- import BigInteger from 'bignumber.js'
2
- import PeerId from 'peer-id'
3
- import CID from 'cids'
4
- import { Block } from './block-service'
5
- import { AbortOptions , Await } from './basic'
6
- import { MovingAverage } from './bitswap/moving-avarage'
7
- import { StoreReader , StoreExporter , StoreImporter } from './store'
1
+ import type BigInteger from 'bignumber.js'
2
+ import type PeerId from 'peer-id'
3
+ import type CID from 'cids'
4
+ import type { Block } from './block-service'
5
+ import type { AbortOptions , Await } from './basic'
6
+ import type { MovingAverage } from './bitswap/moving-avarage'
7
+ import type { StoreReader , StoreExporter , StoreImporter } from './store'
8
8
9
9
export interface Bitswap extends
10
10
StoreReader < CID , Block > ,
@@ -17,19 +17,27 @@ export interface Bitswap extends
17
17
disableStats : ( ) => void
18
18
19
19
wantlistForPeer : ( peerId : PeerId , options ?: AbortOptions ) => Map < string , WantListEntry >
20
- ledgerForPeer : ( peerId : PeerId ) => Ledger
20
+ ledgerForPeer : ( peerId : PeerId ) => null | LedgerForPeer
21
21
22
22
put : ( block : Block , options ?: AbortOptions ) => Await < void >
23
23
24
- unwant : ( cids : Iterable < CID > , options ?: AbortOptions ) => void
25
- cancelWants : ( cids : Iterable < CID > ) => void
24
+ unwant : ( cids : CID | CID [ ] , options ?: AbortOptions ) => void
25
+ cancelWants : ( cids : CID | CID [ ] ) => void
26
26
getWantlist : ( options ?: AbortOptions ) => Iterable < [ string , WantListEntry ] >
27
27
peers : ( ) => PeerId [ ]
28
28
stat : ( ) => Stats
29
29
start : ( ) => void
30
30
stop : ( ) => void
31
31
}
32
32
33
+ export interface LedgerForPeer {
34
+ peer : string
35
+ value : number
36
+ sent : number
37
+ recv : number
38
+ exchanged : number
39
+ }
40
+
33
41
export interface Ledger {
34
42
sentBytes : ( n : number ) => void
35
43
receivedBytes : ( n : number ) => void
@@ -87,5 +95,5 @@ export interface Stats {
87
95
stop : ( ) => void
88
96
readonly snapshot : Record < string , BigInteger >
89
97
readonly movingAverages : Record < string , Record < number , MovingAverage > >
90
- push : ( counter : number , inc : number ) => void
98
+ push : ( peer : string | null , counter : string , inc : number ) => void
91
99
}
0 commit comments