From 0c40084d88164a6c33ac2d0a82fca0b70be5cee8 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Tue, 30 Jan 2018 04:06:20 +0000 Subject: [PATCH] feat: Link stats.repo and stats.bitswap (#210) * Update BITSWAP.md * Update STATS.md * Update BITSWAP.md * Update REPO.md --- SPEC/BITSWAP.md | 51 ++++++++++++++++++++++++++++++++-- SPEC/REPO.md | 2 ++ SPEC/STATS.md | 74 ++----------------------------------------------- 3 files changed, 54 insertions(+), 73 deletions(-) diff --git a/SPEC/BITSWAP.md b/SPEC/BITSWAP.md index 2c9683a947..7971070f5e 100644 --- a/SPEC/BITSWAP.md +++ b/SPEC/BITSWAP.md @@ -1,2 +1,49 @@ -bitswap API (not spec'ed yet) -============================= +Bitswap API +======= + +#### `wantlist` (not spec'ed yet) + +#### `unwant` (not spec'ed yet) + +#### `stat` + +> Adds an IPFS object to the pinset and also stores it to the IPFS repo. pinset is the set of hashes currently pinned (not gc'able). + +##### `Go` **WIP** + +##### `JavaScript` - ipfs.bitswap.stat([callback]) + +`stats.bitswap` and `bitswap.stat` can be used interchangeably. + +`callback` must follow `function (err, stats) {}` signature, where `err` is an error if the operation was not successful. `stats` is an Object containing the following keys: + +- `provideBufLen` +- `wantlist` (array) +- `peers` (array) +- `blocksReceived` +- `dataReceived` +- `blocksSent` +- `dataSent` +- `dupBlksReceived` +- `dupDataReceived` + +If no `callback` is passed, a promise is returned. + +**Example:** + +```JavaScript +ipfs.stats.bitswap((err, stats) => console.log(stats)) + +// { provideBufLen: 0, +// wantlist: null, +// peers: +// [ 'QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM', +// 'QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu', +// 'QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd' ], +// blocksReceived: 0, +// dataReceived: 0, +// blocksSent: 0, +// dataSent: 0, +// dupBlksReceived: 0, +// dupDataReceived: 0 } +``` diff --git a/SPEC/REPO.md b/SPEC/REPO.md index a90cf0b12f..218a3929fc 100644 --- a/SPEC/REPO.md +++ b/SPEC/REPO.md @@ -33,6 +33,8 @@ ipfs.repo.gc((err, res) => console.log(res)) ##### `JavaScript` - ipfs.repo.stat([options, callback]) +`stats.repo` and `repo.stat` can be used interchangeably. + Where: - `options` is an object that contains following properties diff --git a/SPEC/STATS.md b/SPEC/STATS.md index 70c6cf7c94..7bcd5f9dfc 100644 --- a/SPEC/STATS.md +++ b/SPEC/STATS.md @@ -3,44 +3,11 @@ Stats API #### `bitswap` -> Adds an IPFS object to the pinset and also stores it to the IPFS repo. pinset is the set of hashes currently pinned (not gc'able). - -##### `Go` **WIP** - -##### `JavaScript` - ipfs.stats.bitswap([callback]) +`stats.bitswap` and `bitswap.stat` can be used interchangeably. See [`bitswap.stat`](./BITSWAP.md#stat) for more details. -`callback` must follow `function (err, stats) {}` signature, where `err` is an error if the operation was not successful. `stats` is an Object containing the following keys: - -- `provideBufLen` -- `wantlist` (array) -- `peers` (array) -- `blocksReceived` -- `dataReceived` -- `blocksSent` -- `dataSent` -- `dupBlksReceived` -- `dupDataReceived` +#### `repo` -If no `callback` is passed, a promise is returned. - -**Example:** - -```JavaScript -ipfs.stats.bitswap((err, stats) => console.log(stats)) - -// { provideBufLen: 0, -// wantlist: null, -// peers: -// [ 'QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM', -// 'QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu', -// 'QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd' ], -// blocksReceived: 0, -// dataReceived: 0, -// blocksSent: 0, -// dataSent: 0, -// dupBlksReceived: 0, -// dupDataReceived: 0 } -``` +`stats.repo` and `repo.stat` can be used interchangeably. See [`repo.stat`](./REPO.md#stat) for more details. #### `bw` @@ -77,38 +44,3 @@ ipfs.stats.bw((err, stats) => console.log(stats)) // rateIn: 905.0873512246716, // rateOut: 893.7400053359125 } ``` - -#### `stat` - -> Get stats for the currently used repo. - -##### `Go` **WIP** - -##### `JavaScript` - ipfs.repo.stat([options, callback]) - -Where: - -- `options` is an object that contains following properties - - `human` a Boolean value to output `repoSize` in MiB. - -`callback` must follow `function (err, stats) {}` signature, where `err` is an Error if the operation was not successful and `stats` is an object containing the following keys: - -- `numObjects` -- `repoSize` -- `repoPath` -- `version` -- `storageMax` - -If no `callback` is passed, a promise is returned. - -**Example:** - -```JavaScript -ipfs.repo.stat((err, stats) => console.log(stats)) - -// { numObjects: 15, -// repoSize: 64190, -// repoPath: 'C:\\Users\\henri\\AppData\\Local\\Temp\\ipfs_687c6eb3da07d3b16fe3c63ce17560e9', -// version: 'fs-repo@6', -// storageMax: 10000000000 } -```