I've read the paper-Kademlia: A Peer-to-peer Information System Based on the XOR Metric. but i still have 2 questions.
Q1:How does a node get its node id?
BEP5 says: Each node has a globally unique identifier known as the "node ID." Node IDs are chosen at random from the same 160-bit space as BitTorrent infohashes .
Then if you choose at random,how do you choose and how to make sure the id you choose is globally unique? I mean somebody may choose the same id as yours.
Q2: How does the node storing the key-value know if some peer leave the swarm?
The paper I mentioned in the first line says:To compensate for nodes leaving the network, Kademlia republishes each key-value pair once an hour.
But if I were the node, i want to update who is still downloading one certain file, i still have no idea who have left the swarm.