Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
ipfs-bitswap
Advanced tools
JavaScript implementation of the Bitswap data exchange protocol used by IPFS
JavaScript implementation of the Bitswap data exchange protocol used by IPFS
$ npm i ipfs-bitswap
<script>
tagLoading this module through a script tag will make it's exports available as IpfsBitswap
in the global namespace.
<script src="https://unpkg.com/ipfs-bitswap/dist/index.min.js"></script>
const bitswapNode = // ...
const stats = bitswapNode.stats
Stats contains a snapshot accessor, a moving average acessor and a peer accessor.
Besides that, it emits "update" events every time it is updated.
stats.on('update', (stats) => {
console.log('latest stats snapshot: %j', stats)
})
You can get the stats for a specific peer by doing:
const peerStats = stats.forPeer(peerId)
The returned object behaves like the root stats accessor (has a snapshot, a moving average accessors and is an event emitter).
const snapshot = stats.snapshot
console.log('stats: %j', snapshot)
the snapshot will contain the following keys, with the values being bignumber.js instances:
// stats: {
// "dataReceived":"96",
// "blocksReceived":"2",
// "dataReceived":"96",
// "dupBlksReceived":"0",
// "dupDataReceived":"0",
// "blocksSent":"0",
// "dataSent":"0",
// "providesBufferLength":"0",
// "wantListLength":"0",
// "peerCount":"1"
// }
const movingAverages = stats.movingAverages
This object contains these properties:
const dataReceivedMovingAverages = movingAverages.dataReceived
Each one of these will contain one key per interval (miliseconds), being the default intervals defined:
You can then select one of them
const oneMinuteDataReceivedMovingAverages = dataReceivedMovingAverages[60000]
This object will be a movingAverage instance.
You can run performance tests like this:
$ npm run benchmarks
You can run each of the individual performance tests with a profiler like 0x.
To do that, you need to install 0x:
$ npm install 0x --global
And then run the test:
$ 0x test/benchmarks/get-many
This will output a flame graph and print the location for it. Use the browser Chrome to open and inspect the generated graph.
Licensed under either of
Contributions welcome! Please check out the issues.
Also see our contributing document for more information on how we work, and about contributing in general.
Please be aware that all interactions related to this repo are subject to the IPFS Code of Conduct.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
FAQs
JavaScript implementation of the Bitswap data exchange protocol used by IPFS
We found that ipfs-bitswap demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.