Readit News logoReadit News
adastra22 · 3 years ago
Thanks, this is really cool. I don't have anything to add; I just want to let the author know this is appreciated. I recently decided to learn Go, and articles like this are a great way to get a feel for how Go programmers think about solving problems with the tools available to them. The kind of knowledge you don't get from just skimming The Go Programming Language and such.
quirino · 3 years ago
I've recently started learning Go and chose a project-based approach. I've been reading "Writing an Interpreter in Go" and "Powerful Command-Line Applications in Go" and it's been loads of fun.
adastra22 · 3 years ago
Thanks for the recommendations!
throwaway894345 · 3 years ago
This didn’t dive into it, but I appreciated the suggested search terms for information on decentralized peer discovery. I always wondered how that would work, especially the bootstrapping process. Ultimately I found this StackOverflow answer to be really helpful: https://stackoverflow.com/a/22240583
banana_giraffe · 3 years ago
One of the things that made the bootstrapping click for me was realizing there are in fact servers that DHT clients talk to once to find an entrance to the network. They all have a list (such as https://github.com/qbittorrent/qBittorrent/blob/c80238d66ff3... )
throaway53dh · 3 years ago
Why is it so hard to in block torrent if all they have to d ok is block these DHT servers
unboxingelf · 3 years ago
As someone who writes Go code daily, nice Go code!
DoctorOW · 3 years ago
One of my favorite things about Go's language design is that difference between really good code and average-level code is much smaller.
mdaniel · 3 years ago
The project author's previous submission: https://news.ycombinator.com/item?id=21958359
andirk · 3 years ago
They're big fans of bittorrent, it appears.
aliqot · 3 years ago
Bit Torrent is a cornerstone of the modern internet.
chrsig · 3 years ago
Great post

One nit, with the font:

    l4:spami7ee
the first two characters look an awful lot like the number "14", when they're actually "L4". I'm not sure if bencoding is case sensitive or if anohter font may better differentiate the two, but that may be something the author may want to poke at if they happen to read this comment :)

pianoben · 3 years ago
I had the same confusion! In my browser, with the default monospace font, the two characters are so similarly as to be indistinguishable.

Reading the next example, showing an encoded dictionary, was what made the penny drop. Bencode doesn't go out of its way to be visually accessible, so different font choices would help.

fazfq · 3 years ago
The l looks taller than the 4 to me, which makes it clear it's not another number
ben_ja_min · 3 years ago
Looks like a one to my bad eyes.
riley_dog · 3 years ago
This looks to have been written on Jan 4, 2020.
merpkz · 3 years ago
> "They’ll send us an unchoke message to let us know that we can begin asking them for data."

What is the purpose of that choke part when connecting to remote peers? Is that some kind of flood protection?

nprateem · 3 years ago
You can normally control the number of peers you share with, so I guess if 50 peers are connected but you only want to share with 10, then when one completes you'd send an unchoke message to another peer to tell it you'll share with them. Meanwhile the other 39 will stay choked. I assume that's what's going on here.
merpkz · 3 years ago
That makes sense, thanks. It just occurred to me how interesting of a challenge it is to write a bittorrent client. There are so much issues to work on, like how to effectively retrieve chunks of files and in meantime balance upload speed equally to remote clients of file parts you actually have already.
3ln00b · 3 years ago
Very helpful. Can someone recommend more of these learn by doing programming blogs?
elcapitan · 3 years ago