GithubHelp home page GithubHelp logo

Comments (4)

nictuku avatar nictuku commented on September 17, 2024

To clarify, the Decode function does fill the outmost dictionary fields, but not the inner one.

Also, encoding that object works - just decoding won't work.

from taipei-torrent.

jackpal avatar jackpal commented on September 17, 2024

Hey, sorry to cause you trouble.

If the torrent protocol doesn't require decoding dictionaries inside of dictionaries, I guess that explains why this bug hasn't been found.

As for how to fix it -- it may be a case where an object is being passed by reference rather than by pointer. So we may be successfully decoding the inner dictionary, but then throwing away that copy rather than saving it in the outer dictionary.

That is a wild guess, but I've had similar bugs in the past. It is error-prone that interface{} works for both references and pointers.

from taipei-torrent.

nictuku avatar nictuku commented on September 17, 2024

Hey, thanks for the reply.

This is required for DHT. See the sample queries in http://www.bittorrent.org/beps/bep_0005.html.

I'll take a shot at this later, and also try to fix a few panics conditions that I managed to generate when doing incorrect calls (e.g: when I inappropriately passed map[string]string{} for a decoding that demanded map[string]interface{}, IIRC).

Another question, would it be too ugly for me to add a safety measure in the bencode library, so it catches all panics before it goes up the stack, so we can show an error instead? That is, only to provide a safety net for really exceptional cases, assuming we can't avoid all panic occurrences in the first place.

from taipei-torrent.

nictuku avatar nictuku commented on September 17, 2024

Problem solved. User error, of course. Dictionary inside dictionaries work, I was just doing the wrong thing.

commit b9b781b on my repository adds a unit test for it.

from taipei-torrent.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.