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'
88
99export interface Bitswap extends
1010 StoreReader < CID , Block > ,
@@ -17,19 +17,27 @@ export interface Bitswap extends
1717 disableStats : ( ) => void
1818
1919 wantlistForPeer : ( peerId : PeerId , options ?: AbortOptions ) => Map < string , WantListEntry >
20- ledgerForPeer : ( peerId : PeerId ) => Ledger
20+ ledgerForPeer : ( peerId : PeerId ) => null | LedgerForPeer
2121
2222 put : ( block : Block , options ?: AbortOptions ) => Await < void >
2323
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
2626 getWantlist : ( options ?: AbortOptions ) => Iterable < [ string , WantListEntry ] >
2727 peers : ( ) => PeerId [ ]
2828 stat : ( ) => Stats
2929 start : ( ) => void
3030 stop : ( ) => void
3131}
3232
33+ export interface LedgerForPeer {
34+ peer : string
35+ value : number
36+ sent : number
37+ recv : number
38+ exchanged : number
39+ }
40+
3341export interface Ledger {
3442 sentBytes : ( n : number ) => void
3543 receivedBytes : ( n : number ) => void
@@ -87,5 +95,5 @@ export interface Stats {
8795 stop : ( ) => void
8896 readonly snapshot : Record < string , BigInteger >
8997 readonly movingAverages : Record < string , Record < number , MovingAverage > >
90- push : ( counter : number , inc : number ) => void
98+ push : ( peer : string | null , counter : string , inc : number ) => void
9199}
0 commit comments