Comments (4)
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.
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.
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.
This is probably irrelevant if I switch to msgpack
from p2p-project.
Related Issues (20)
- Switch serialization to msgpack HOT 1
- EventEmitter API Support HOT 1
- Investigate type hinting support
- Add support for FordSocket HOT 1
- Refactor class names
- Fragment Python files
- Update documentation
- WebExtension for networking improvements on the browser
- Add ChordSocket.lock(key) and ChordSocket.unlock(key) HOT 1
- Implement Python Websocket Support HOT 1
- Long Term: Reorganize Repository HOT 2
- Investigate invalid messages during bootstrap HOT 1
- Update contribution section
- Support UDP? HOT 2
- is this project similar to: pyp2p ? HOT 4
- Bug: pip install (python) HOT 3
- Automatically finding Nodes HOT 1
- RuntimeError: Set changed size during iteration HOT 5
- How to do NAT traversal ? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from p2p-project.