Bitswap ledger shows no transferred data

Hi there :smile: ,

During an ipfs get of a large file I do only see empty ledger output like this:

Ledger for <peer.ID Qm*7pXNWF>
Debt ratio:	0.000000
Exchanges:	0
Bytes sent:	0
Bytes received:	0

Here what I did in parallel:

Watch for any non-empty ledger output

while true
  for i in $(ipfs bitswap wantlist)
    ipfs bitswap ledger $i
  done | grep -v Qm | egrep -v '^$' | grep -v '\t0$' | grep -v '\t0.000000$'

Constantly check the wantlist is not empty

while true
  sleep 1
  ipfs bitswap wantlist

Download a big file

ipfs get -o /tmp/bigfile QmYi6yy3ygc3dNJETqFvvyXdZx28dNyNbZLHkiimhd8Jzd
Saving file(s) to /tmp/bigfile
 22.01 MiB / 22.01 MiB [=================================================================================================] 100.00% 2m1s

None of the transferred data did create a non-empty ledger output.

Any ideas? Frankly, I think it’s a bug. Should I open an issue?

Cheers, Stefan

I don’t think this makes any sense. The output from ipfs bitswap wantlist is a list of content multihashes that your node wants. You’re then taking the list of content multihashes and putting it into ipfs bitswap ledger which is expecting peer IDs.

I think you should instead be taking the output from ipfs bitswap peers, parsing out the peer ID, then passing that into ipfs bitswap ledger.

For example, if I do this on my node I get non-zero output for some peers.

ipfs swarm peers | rev | cut -d/ -f1 | rev | xargs -L1 ipfs bitswap ledger | grep -v "\t0$" | grep "Bytes"

edit: or maybe parsing the list of partners from ipfs bitswap stat would be better than just the current peers from ipfs swarm peers? It looks like there are more bitswap partners than current peers, so maybe that would let you look up the ledgers for all peers since node startup.

Thanks for the answer - sometimes I’m sooooo stupid :blush:

I was so focused on testing my stuff, that I was not controlling the output of ipfs bitswap wantlist.

You’re completely right.

ipfs bitswap wantlist gives back a hash but not one of a peer id as needed for ipfs bitswap ledger.

1 Like

Here the result for the time being.

Comments are always appreciated :smile:

1 Like