Git Product home page Git Product logo

Comments (12)

lukechampine avatar lukechampine commented on August 12, 2024

Should be easy enough. int and uint already cause panics if you try to marshal them.

What about length-prefixes? Should they all be 8 bytes too?

Also, I'm confused a bit by "we don't need to send the marshalled types over a wire." How else would we encode them?

from sia.

DavidVorick avatar DavidVorick commented on August 12, 2024

json or msgpack. we could also use a compressed version of the marshalled stuff, or uncompressed. When sending over a wire you have much better flexibility.

We'll use the marshalled stuff at first but we can change how we send messages without breaking the protocol.

from sia.

lukechampine avatar lukechampine commented on August 12, 2024

hmm. I don't really see the value in using a different serialization format for the network stuff, except to make the API a bit friendlier. And even then, the flexibility of json or msgpack seems unnecessary when we only have 4 or 5 message types. That's few enough that you could decode each of them manually without too much trouble.

I'd be wary of compression too, since it means another step and another library for library writers. It might be worth it if the size reduction is significant, but my gut feeling is that most of our messages are moderately entropic already.

from sia.

DavidVorick avatar DavidVorick commented on August 12, 2024

It's all stuff for later anyway. Just using normal sia marshalling is good enough for now.

from sia.

DavidVorick avatar DavidVorick commented on August 12, 2024

So..., in the process of implementing, it suddenly doesn't seem like such a bad thing to let int and uint get marshalled. Before it was bad because they had an undefined size, but we've since enforced that all integer types get encoded as 8 bytes, which means it no longer seems like a crime to marshal an int. Forcing everything to come out as 8 bytes makes life easier.

from sia.

DavidVorick avatar DavidVorick commented on August 12, 2024

I think that EncUint64 and it's 3 cousin functions should all be non-exported from the encoding package.

I don't like seeing EncUint64 being used within the Sia package because it reduces modularity - if for whatever reason we decide to do something different for encoding, there are a lot more places to hunt down the functions. But if they always use Marshal and Unmarshal, then changing how the marshalling works won't cause problems elsewhere in the codebase.

from sia.

DavidVorick avatar DavidVorick commented on August 12, 2024

Want to close this issue, but want to first check that it's been fixed.

All numbers are always 8 bytes?

I'm also tossing around the idea that they should always be signed, but not fully sold on that idea.

from sia.

lukechampine avatar lukechampine commented on August 12, 2024

Everything is encoded as 8 bytes, yes. int_s are encoded as int64s and uint_s are encoded as uint64s. However, length prefixes are only 4 bytes. We might want to change this to 8 for consistency.

from sia.

DavidVorick avatar DavidVorick commented on August 12, 2024

Sounds good to me.

Ultimately I thinking to encoding all ints as int64's (uint64 included) is going to be the right move, but there are a lot of things you need to be careful about with regards to wrapping, so we're just going to leave that out for now, and let ints and uints be different.

I can close this issue once length prefixes are 8 bytes.

from sia.

DavidVorick avatar DavidVorick commented on August 12, 2024

Update on this?

from sia.

lukechampine avatar lukechampine commented on August 12, 2024

length prefixes are still 4 bytes, and encoding prefixes are just 1 byte. I'll make them both 8 bytes in my next PR.

from sia.

lukechampine avatar lukechampine commented on August 12, 2024

Fixed by #88

from sia.

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.