How do peers get added to bitswap partner list

I want to know how are the peers the a node is connected to gets added to the bitswap peers list.

my partner list returns zero when I do ipfs bitswap stats.

Thank you

All the nodes you are connected effectively become added.
I changed the partner list a couple of months ago so that it lazily adds peers that first send a message, this is to save on memory, if a peer never requested data from us we don’t need to track it.

Thank you for the response.
So if a peer in the private network does not request any data from our node (because it is not asked for any data by the user currently), it would not get added to the bitswap partner list. Only once it has exchanged some data it gets added to that list. Is that understanding correct?.

Thank you

I am also seeing a lot of swarm connect failures with this message

[/ip4/<node-ip>/tcp/<port>] failed to negotiate security protocol: error reading handshake message: noise: message is too short

Would be grateful if you could help with this as well. What could be causing it. All the nodes are running fine but when trying to do swarm connect with api, It failed to connect with 500 error

Yes, when your node receives a WANT_* request.
It also gets removed when the peer disconnects.

Do you have different swarm keys on different nodes ? Or some nodes don’t have the swarm key ?

No the swarm keys are the same