GithubHelp home page GithubHelp logo

Comments (4)

LivInTheLookingGlass avatar LivInTheLookingGlass commented on July 30, 2024

The proposal in #113 would come out to be significantly more complicated.

EncodedMessage = TupleLength SerializedTuple ;
SerializedTuple = TupleItem TupleItem TupleItem TupleItem TupleItem* ;
TupleItem = TupleLength TupleType SerializedItem ;
TupleLength = UnsignedBigEndianInt{4} ;
TupleType = UnsignedBigEndianInt{1} ;
SerializedItem = UnsignedBigEndianInt{1} |
                 UnsignedBigEndianInt{2} |
                 UnsignedBigEndianInt{4} |
                 UnsignedBigEndianInt{8} |
                 BigEndianInt{1} |
                 BigEndianInt{2} |
                 BigEndianInt{4} |
                 BigEndianInt{8} |
                 SerializedTuple |
                 BigInt |
                 .* ;
BigInt = ('+' | '-') .+ ;

forEvery EncodedMessage : length(SerializedTuple) == TupleLength ;
forEvery TupleItem : length(SerializedItem) == TupleLength ;

// Typing schemes
forEvery TupleItem : (TupleType == 0x33 or TupleType == 0x34) implies length(SerializedItem) == 1 ;
forEvery TupleItem : (TupleType == 0x35 or TupleType == 0x36) implies length(SerializedItem) == 2 ;
forEvery TupleItem : (TupleType == 0x37 or TupleType == 0x38) implies length(SerializedItem) == 4 ;
forEvery TupleItem : (TupleType == 0x39 or TupleType == 0x3A) implies length(SerializedItem) == 8 ;
forEvery TupleItem : (TupleType == 0x32) implies length(SerializedItem) >= 10 and SerializedItem[0] in < '+', '-' > ;

// SerializedTuple item 1 is pathfinding header
// SerializedTuple item 2 is sender ID
// SerializedTuple item 3 is checksum
// SerializedTuple item 4 is timestamp
// SerializedTuple item 5+ are user defined payload

from p2p-project.

LivInTheLookingGlass avatar LivInTheLookingGlass commented on July 30, 2024

The proposal in #84 would look like:

EncodedMessage = shortLength TupleLength SerializedTuple ;
SerializedTuple = TupleItem TupleItem TupleItem TupleItem TupleItem* ;
TupleItem = shortLength TupleLength SerializedItem ;
shortItem = UnsignedBigEndianInt{1}
TupleLength = UnsignedBigEndianInt{shortLength} ;
SerializedItem = .{TupleLength}

// These rules are redundant for clarity
forEvery EncodedMessage : length(TupleLength) == shortLength ;
forEvery EncodedMessage : length(SerializedTuple) == TupleLength ;
forEvery TupleItem : length(TupleLength) == shotLength ;
forEvery TupleItem : length(SerializedItem) == TupleLength ;

// SerializedTuple item 1 is pathfinding header
// SerializedTuple item 2 is sender ID
// SerializedTuple item 3 is checksum
// SerializedTuple item 4 is timestamp
// SerializedTuple item 5+ are user defined payload

This definition would restrict TupleLengths to being either 1, 2, 4, or 8 bytes long

from p2p-project.

LivInTheLookingGlass avatar LivInTheLookingGlass commented on July 30, 2024

Combining #113 and #84 would look like:

EncodedMessage = shortLength TupleLength SerializedTuple ;
SerializedTuple = TupleItem TupleItem TupleItem TupleItem TupleItem* ;
TupleItem = shortLength TupleLength TupleType SerializedItem ;
shortLength = UnsignedBigEndianInt{1} ;
TupleLength = UnsignedBigEndianInt{shortLength} ;
TupleType = UnsignedBigEndianInt{1} ;
SerializedItem = UnsignedBigEndianInt{1} |
                 UnsignedBigEndianInt{2} |
                 UnsignedBigEndianInt{4} |
                 UnsignedBigEndianInt{8} |
                 BigEndianInt{1} |
                 BigEndianInt{2} |
                 BigEndianInt{4} |
                 BigEndianInt{8} |
                 SerializedTuple |
                 BigInt |
                 .* ;
BigInt = ('+' | '-') .+ ;

forEvery EncodedMessage : length(TupleLength) == shortLength ;
forEvery EncodedMessage : length(SerializedTuple) == TupleLength ;
forEvery TupleItem : length(TupleLength) == shotLength ;
forEvery TupleItem : length(SerializedItem) == TupleLength ;

// Typing schemes
forEvery TupleItem : (TupleType == 0x33 or TupleType == 0x34) implies length(SerializedItem) == 1 ;
forEvery TupleItem : (TupleType == 0x35 or TupleType == 0x36) implies length(SerializedItem) == 2 ;
forEvery TupleItem : (TupleType == 0x37 or TupleType == 0x38) implies length(SerializedItem) == 4 ;
forEvery TupleItem : (TupleType == 0x39 or TupleType == 0x3A) implies length(SerializedItem) == 8 ;
forEvery TupleItem : (TupleType == 0x32) implies length(SerializedItem) >= 10 and SerializedItem[0] in < '+', '-' > ;

// SerializedTuple item 1 is pathfinding header
// SerializedTuple item 2 is sender ID
// SerializedTuple item 3 is checksum
// SerializedTuple item 4 is timestamp
// SerializedTuple item 5+ are user defined payload

This definition would restrict TupleLengths to being either 1, 2, 4, or 8 bytes long

from p2p-project.

LivInTheLookingGlass avatar LivInTheLookingGlass commented on July 30, 2024

This is probably irrelevant if I switch to msgpack

from p2p-project.

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.