TBD54566975 / web5-go

Apache License 2.0
10 stars 6 forks source link

handroll bencode #46

Closed mistermoe closed 6 months ago

mistermoe commented 6 months ago

Overview

First-pass run-through at handrolling bencode to replace usage of "github.com/anacrolix/torrent/bencode". No qualms with the lib itself it just happens to be a full fledged bittorrent client package

[!NOTE] What's in this PR at the very least fulfills the needs of did:dht

Rationale

The lib we're depending on adds 627 dependencies to our dependency graph. removing it brought the dep count down to 15. I recently had to handroll bencode in kotlin and have to do it again in dart so it was fresh on my mind. Figured i might as well knock it out here before forgetting all about it.

[!WARNING] I'm not sure my implementation is idiomatic go. i looked at the anacrolix implementation and it looks pretty involved. I kept the API surface that we're using identical to the 3rd party dep. my variable names are kaka bc i wrote most of this during meetings. definitely open to renaming stuff if the names are jarring