anacrolix / dht

dht is used by anacrolix/torrent, and is intended for use as a library in other projects both torrent related and otherwise
Mozilla Public License 2.0
313 stars 66 forks source link

do not start a goroutine on import #43

Closed trim21 closed 3 years ago

trim21 commented 3 years ago

I'm trying to use this as part of my project, and the BT/DHT function is not always needed, it's only some part of my application.

So the dht/v2 as a library start a goroutine in the background running forever is very weird.

I think this goroutine should be started when the BT client is created, not the library is imported, library itself shoule bt side-effect free.

anacrolix commented 3 years ago

That's fair, but what goroutine?

trim21 commented 3 years ago

@anacrolix

the init() function I found

https://github.com/anacrolix/dht/blob/8664e9f7c6297c595065b6345b13e71bdad47c74/dht.go#L106-L108

anacrolix commented 3 years ago

@Trim21 Thanks!

anacrolix commented 3 years ago

@Trim21 can you take a look at the PR?

trim21 commented 3 years ago

Looks good

trim21 commented 3 years ago

Thanks