7

We are building a desktop app, on Electron, to share media on IPFS. We want to incentivize the people, who either by an IPFS add or pin, make data available to other users and in effect are "seeding" the data. We want to track how much data is being sent and received by each user, programmatically and periodically.

Is there a standard pattern or a service to be able to do this?

TIA!

Vishal
  • 887
  • 9
  • 22
  • 1
    There is a general incentive mechanism for ipfs which is filecoin by the same team. Instead of relying on data sent/received by a node, it relies on proof of replication that guarantees data is replicated. If you want check the data sent/received by ipfs, you can use a general OS utility like `nethogs` (Linux) – riteshtch Feb 18 '18 at 15:45

1 Answers1

2

On the CLI you can use the ipfs stats bw -p <peer id> command to see the total bytes sent and recieved between your node and the peer id you pass in.

$ ipfs stats bw -p  QmeMKDA6HbDD8Bwb4WoAQ7s9oKZTBpy55YFKG1RSHnBz6a
Bandwidth
TotalIn: 875 B
TotalOut: 14 kB
RateIn: 0 B/s
RateOut: 0 B/s

See: https://docs.ipfs.io/reference/api/cli/#ipfs-stats-bw

You can use the ipfs.stats.bw method to the data programatically from the js implementation of IPFS js-ipfs or via the js-ipfs-http-client talking to the http api of a locally running ipfs daemon.

ipfs.stats.bw will show all traffic between to peers, which can include dht queries and other traffic that isn't directly related to sharing blocks of data.

If you want info on just blocks of data shared then you can use ipfs bitswap ledger from the command line.

$ ipfs bitswap ledger QmeMKDA6HbDD8Bwb4WoAQ7s9oKZTBpy55YFKG1RSHnBz6a
Ledger for QmeMKDA6HbDD8Bwb4WoAQ7s9oKZTBpy55YFKG1RSHnBz6a
Debt ratio: 0.000000
Exchanges:  0
Bytes sent: 0
Bytes received: 0

See: https://docs.ipfs.io/reference/api/cli/#ipfs-bitswap-ledger

That api is not directly available in js-ipfs or the js-http-api-client yet.

olizilla
  • 436
  • 4
  • 6