-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
420 changed files
with
6,248 additions
and
4,503 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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import last from 'it-last' | ||
import { normaliseInput } from 'ipfs-core-utils/files/normalise-input-single' | ||
import { createAddAll } from './add-all.js' | ||
import type { Client } from './lib/core.js' | ||
import type { AddOptions, AddResult } from './root.js' | ||
import type { ImportCandidate } from './index.js' | ||
|
||
export function createAdd (client: Client) { | ||
const all = createAddAll(client) | ||
async function add (input: ImportCandidate, options?: AddOptions): Promise<AddResult> { | ||
const source = normaliseInput(input) | ||
// @ts-expect-error - all may return undefined if source is empty | ||
const addAllPromise = all(source, options) | ||
// @ts-expect-error - last may return undefined if source is empty | ||
return await last(addAllPromise) | ||
} | ||
return add | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { createWantlist } from './wantlist.js' | ||
import { createStat } from './stat.js' | ||
import type { PeerId } from '@libp2p/interface-peer-id' | ||
import type { CID } from 'multiformats' | ||
import type { Client } from '../lib/core.js' | ||
import type { ClientOptions } from '../index.js' | ||
|
||
export function createBitswap (client: Client): BitswapAPI { | ||
// TODO: https://github.com/ipfs/js-kubo-rpc-client/issues/99 | ||
return { | ||
wantlist: createWantlist(client), | ||
stat: createStat(client) | ||
} | ||
} | ||
|
||
export interface WantlistOptions extends ClientOptions { | ||
peer: PeerId | ||
} | ||
|
||
export interface BitswapAPI { | ||
/** | ||
* Returns the wantlist for your node | ||
* | ||
* @example | ||
* ```js | ||
* const list = await ipfs.bitswap.wantlist() | ||
* console.log(list) | ||
* // [ CID('QmHash') ] | ||
* ``` | ||
*/ | ||
wantlist: (options?: WantlistOptions) => Promise<CID[]> | ||
|
||
/** | ||
* Show diagnostic information on the bitswap agent. | ||
* Note: `bitswap.stat` and `stats.bitswap` can be used interchangeably. | ||
* | ||
* @example | ||
* ```js | ||
* const stats = await ipfs.bitswap.stat() | ||
* console.log(stats) | ||
* ``` | ||
*/ | ||
stat: (options?: ClientOptions) => Promise<Stats> | ||
} | ||
|
||
export interface Stats { | ||
provideBufLen: number | ||
wantlist: CID[] | ||
peers: PeerId[] | ||
blocksReceived: bigint | ||
dataReceived: bigint | ||
blocksSent: bigint | ||
dataSent: bigint | ||
dupBlksReceived: bigint | ||
dupDataReceived: bigint | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.